这个简单,你做一个链接列,在链接列的URL指定Message.aspx?ID={0},并指定绑定的字段为员工的ID
解决方案 »
- 引用问题
- C# GDI+ 绘图 各位速来讨论 在线等你们的意见哦 !
- 江湖救急啊,“程兴亮”大哥请进
- 第三张贴,大侠请进,DataGridView怎样设置?
- 是否有办法防止被探测到使用了代理?
- 获取远程网页回显内容时提示500错误怎么办?
- 出来混了大半年了,明天第一次回家,散分同时问个问题
- 求助:一个反转字符串的方法
- windows窗口大小改变后,里面控件的大小和位置怎么相应改变啊?
- 请问怎样动态的改变dataGrid中的数据。帮我看看这段代码为什么不行。
- <%# DataBinder.Eval(Container.DataItem, "Price", "{0:c}") %>这里的{0:c}是什么意思?还有什么样的形式?
- 我如何把网上的流媒体录制到本地?
Page.RegisterStartupScript ("mywindow","<script language=javascript>window.open('详细信息URL?ID="+DataGrid中被选行的记录ID+"','mywindow','width=232,height=250,left=8,top=8,toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no, alwaysRaised')</script>");在详细信息页中
显示ID=Request.QueryString["ID"]的详细信息。
Page.RegisterStartupScript ("mywindow","<script language=javascript>window.open('详细信息URL?ID="+DataGrid中被选行的记录ID+"','mywindow')</script>");在详细信息页中
显示ID=Request.QueryString["ID"]的详细信息。
然后在datagrid1_dataitembound事件中:实例化这个按钮
Button btn=(Button)e.item.cell[模版列索引号].findcontrol("button1");
btn.commandargument=员工的编号(就是能唯一确定员工的一个辆);
在datagrid1_itemcommand事件中
string id=e.commandargument.tostring();
然后调用javascript脚本的windows.open()方法打开一个新页,同时将那个员工id做为参数传递就可以了
显示ID=Request.QueryString["ID"]的详细信息。怎么做啊??是不是能获得id的值?
要不就定义个public static变量也可以
楼上的几位方法都可以实现。
SqlDataAdapter sqladp=new SqlDataAdapter ("select *from 职工信息表 where 代号=ID",conn);明显不行啊,请大家帮忙,很菜了,呵呵!!
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<html>
<script runat="server">
ICollection CreateDataSource()
{
DataTable dt = new DataTable();
DataRow dr;
dt.Columns.Add(new DataColumn("IntegerValue", typeof(Int32)));
dt.Columns.Add(new DataColumn("StringValue", typeof(string)));
dt.Columns.Add(new DataColumn("CurrencyValue", typeof(double)));
for (int i = 0; i < 5; i++)
{
dr = dt.NewRow();
dr[0] = i;
dr[1] = "Item " + i.ToString();
dr[2] = 1.23 * (i+1);
dt.Rows.Add(dr);
}
DataView dv = new DataView(dt);
return dv;
}
void Page_Load(Object sender, EventArgs e)
{
if (!IsPostBack)
{
// Load this data only once.
ItemsGrid.DataSource = CreateDataSource();
ItemsGrid.DataBind();
}
}
void Item_Bound(Object sender, DataGridItemEventArgs e)
{ ListItemType itemType = (ListItemType)e.Item.ItemType; if ((itemType != ListItemType.Header) &&
(itemType != ListItemType.Footer) &&
(itemType != ListItemType.Separator))
{ // Get the IntegerValue cell from the grid's column collection.
TableCell intCell = (TableCell)e.Item.Controls[0]; // Add attributes to the cell.
intCell.Attributes.Add("id", "intCell" + e.Item.ItemIndex.ToString());
intCell.Attributes.Add("OnClick",
"Update_intCell" +
e.Item.ItemIndex.ToString() +
"()"); // Add attributes to the row.
e.Item.Attributes.Add("id", "row" + e.Item.ItemIndex.ToString());
e.Item.Attributes.Add("OnDblClick",
"Update_row" +
e.Item.ItemIndex.ToString() +
"()");
}
}
</script><script language="vbscript"> sub Update_intCell0
Alert "You Selected Cell 0."
end sub sub Update_intCell1
Alert "You Selected Cell 1."
end sub sub Update_intCell2
Alert "You Selected Cell 2."
end sub sub Update_intCell3
Alert "You Selected Cell 3."
end sub sub Update_intCell4
Alert "You Selected Cell 4."
end sub sub UpDate_row0
Alert "You selected the row 0."
end sub sub UpDate_row1
Alert "You selected the row 1."
end sub sub UpDate_row2
Alert "You selected the row 2."
end sub sub UpDate_row3
Alert "You selected the row 3."
end sub sub UpDate_row4
Alert "You selected the row 4."
end sub </script>
<body>
<form runat=server> <h3>
Adding Attributes to the <td> and <tr> <br>
Tags of a DataGrid Control
</h3>
<asp:DataGrid id="ItemsGrid" runat="server"
BorderColor="black"
BorderWidth="1"
CellPadding="3"
ShowFooter="true"
OnItemDataBound="Item_Bound"
AutoGenerateColumns="false"> <HeaderStyle BackColor="#00aaaa">
</HeaderStyle> <FooterStyle BackColor="#00aaaa">
</FooterStyle> <Columns> <asp:BoundColumn HeaderText="Number"
DataField="IntegerValue"> <ItemStyle BackColor="yellow">
</ItemStyle>
</asp:BoundColumn> <asp:BoundColumn
HeaderText="Item"
DataField="StringValue"/> <asp:BoundColumn
HeaderText="Price"
DataField="CurrencyValue"
DataFormatString="{0:c}"> <ItemStyle HorizontalAlign="right">
</ItemStyle>
</asp:BoundColumn> </Columns>
</asp:DataGrid> <br><br> Click on one of the cells in the <b>Number</b> column to select the cell. <br><br> Double click on a row to select a row.
</form>
</body>
</html>