单击模板按钮后如何获取行索引? [英] How to get row index on click on template button ?

查看:95
本文介绍了单击模板按钮后如何获取行索引?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生

我已经在Web窗体的网格视图"中使用了模板按钮,并且我想在用户单击模板按钮时检索行索引.我怎样才能做到这一点 ?先生,请帮帮我..


提前查看...

Sir

I have taken a template button in Grid View of a web form and i want to retrieve the row index when a user click on the template button. How can i do that ? Please help me sir ..


thakns in advance...

推荐答案

关于gridview的行命令
on row command of gridview
protected void cmd_transfer(object sender, GridViewCommandEventArgs e)
   {
       int index = Convert.ToInt32(e.CommandArgument);
       GridViewRow row = GridView1.Rows[index];
       ViewState["fileno"] = row.Cells[2].Text;

       this.modal1.Show();
   }




您可以通过任何一种方式在此处检索到该信息

Hi,

You can retrieve that in any way one of the way is here

//On row command event
  int rindex=e.rowIndex



最好的



All the Best




这是获取网格的行索引的一种方法

示例代码:



here is one of the way to get the row index of the grid

the sample code:

protected void grd_RowCommand(object sender, GridViewCommandEventArgs e)
{
int index = grd.PageIndex * grd.PageSize + Convert.ToInt32(e.CommandArgument);
}



这里的命令参数就像



Here command argument is like

CommandArgument=''<%#Container.DisplayIndex%>''



希望它能工作



Hope it will work


这篇关于单击模板按钮后如何获取行索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆