asp.net获得数据控件事件索引并获取其中值总结
程序员文章站
2024-03-06 15:24:38
复制代码 代码如下: 1、rowcommad //获得索引 int index = ((gridviewrow)(((button)(e.commandsource)).p...
复制代码 代码如下:
1、rowcommad
//获得索引
int index = ((gridviewrow)(((button)(e.commandsource)).parent.parent)).rowindex;
2、rowediting等
//获得索引
int index = e.neweditindex;
//获取当前gridviewrow对象
gridviewrow editgridviewrow = autogridview.rows[girdvieweditindex];
//获取内容方法一 row中有控件label
label girdviewtitlelabel = editgridviewrow.cells[0].findcontrol("titlelabel") as label;
string gridviewcontent = girdviewtitlelabel.text;
//获取内容方法二 row中有无控件label
//string gridviewcontent = editgridviewrow.cells[0].text;
3、rowdeleting等
//获得索引
int index=e.rowindex ;
//获取当前gridviewrow对象
gridviewrow gvr=autogridview.rows[index];
//取得当前行第二个单元格中的文字
string str = gvr.cells[1].text;
上一篇: JDK环境变量配置