| 发表于:2007-05-16 19:50:204楼 得分:0 |
gridviewcommandeventargs 类未包含一个用于指示单击按钮所在行的属性。如果需要知道哪个行引发了事件,请使用 commandargument 属性将行的索引传给事件处理方法。 所以你要先在rowcreated(其中test是按钮的commandname) protected void gridview1_rowcreated(object sender, gridviewroweventargs e) { linkbutton addbutton ; if (e.row.rowtype == datacontrolrowtype.datarow) { addbutton = (linkbutton)e.row.cells[1].controls[0]; if (addbutton != null) { if (addbutton.commandname== "test ") addbutton.commandargument = e.row.rowindex.tostring(); } } } 然后在rowcommand事件中 protected void gridview1_rowcommand(object sender, gridviewcommandeventargs e) { if (e.commandname == "test ") { dropdownlist droptemp = (dropdownlist)gridview1.rows[convert.toint32(e.commandargument)].cells[2].findcontrol( "droptemp "); if (droptemp != null) { response.write(droptemp.text); } } } | | |
|