在 gridview 的 onrowcommand 事件中 如何获取所点击的行的索引值啊 protected void Button1_Click(object sender, GridViewPageEventArgs e)
{
Response.Redirect("dailyDetail1.aspx?did=" + this.dbgDaily.Rows[e.].Cells[1].Text);
}
{
Response.Redirect("dailyDetail1.aspx?did=" + this.dbgDaily.Rows[e.].Cells[1].Text);
}
解决方案 »
- 关于Discuz!NT出现乱码,哪位仁兄遇到过?
- “Microsoft.ApplicationBlocks.Data.SqlHelper”并不包含“ConnectionStringLocalTrans
- 发布出来的文章为什么标题没有读了来,请高手支招.
- SQL问题,请指教谢谢
- 文件上传后出现错误,但在本机上调试成功,错误如下,请各位高手指点
- 请问我写完一个插入语句以后,怎样将文本框清空?
- 跪求ajax里面的htmleditor的用法
- 请教:用asp.net做基于web的程序和做网站有什么样的区别(来者有分)
- 这个事业单位的网站 值多少钱?
- word进程如何结束?已经困扰我好久了,谢谢大家来帮忙!
- 给定死的宽度,为什么会变形?
- 有关gridview效率问题
你可以设置DataKeys来获取内容……
int index = Convert.ToInt32(e.CommandArgument);
onselectedindexchanging="GridView1_SelectedIndexChanging">
<Columns>
<asp:BoundField HeaderText="第一列" />
<asp:BoundField HeaderText="第二列" />
<asp:CommandField ShowSelectButton="True" />
</Columns>
</asp:GridView>后台这样写:protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
int index = e.NewSelectedIndex;
}
protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
Response.Redirect("dailyDetail1.aspx?did=" + this.GridView1.Rows[e.NewSelectedIndex].Cells[1].Text);
}
GridViewRow row = lnk.NamingContainer as GridViewRow;row.RowIndex就是索引值
{
if (e.CommandName == "btd")
{
int intRow = int.Parse(e.CommandArgument.ToString()); //获取当前所在行
// string strUniqueID = grdSignedAss.DataKeys[intRow].Value.ToString();
} }