Html:
CS:protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) {
if (e.CommandName.ToString().Trim() == "Edit")
{
string ClDId = ((Label)(GridView1.Rows[Convert.ToInt32(e.CommandArgument)].FindControl("Lab_DId"))).Text.Trim();//e.CommandArgument调试数据为空
string ClDId1 = ((Label)(GridView1.SelectedRow.FindControl("Lab_DId"))).Text.Trim();}
}
RowDataBound事件里面把行的索引绑定到button的CommandArgument 属性上面!
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton rb = (LinkButton)e.Row.FindControl("LinkButton1");
if (rb != null)
rb.CommandArgument = e.Row.RowIndex.ToString(); //把选中行的RowIndex也传过去,提交后在服务器端取值时用
}
}
然后rowcommand事件里面这么写就找到啦!
Label lab1 = (Label)(GridView1.Rows[int.Parse(e.CommandArgument.ToString())].FindControl("Label1"));
相关文章:
-
2022-12-23
-
2022-12-23
-
2021-10-28
-
2022-12-23
-
2021-08-21
猜你喜欢
-
2021-06-26
-
2022-12-23
-
2021-06-09
-
2022-12-23
-
2022-12-23
-
2021-09-24
-
2022-01-09
相关资源
-
下载
2023-02-02
-
下载
2021-06-24
-
下载
2023-01-01
-
下载
2021-06-26