1、gridview1_rowcommand(object sender, gridviewcommandeventargs e)中根據gridviewcommandeventargs e得到該行物件gridviewrow:
(gridviewrow)((linkbutton)e.commandsource).parent.parent
進而可以得到該行中某列中的值:((gridviewrow)((linkbutton)e.commandsource).parent.parent).cells[2].text
2、gridview1_rowdatabound(object sender, gridviewroweventargs e)中根據gridviewroweventargs e得到該行物件:
if (e.row.rowtype == datacontrolrowtype.datarow)
{e.row
得到該行資料來源:
datarowview drv = (datarowview)e.row.dataitem;
3、根據行索引獲得該行主鍵值datakey:
gridview1.datakeys[e.rowindex].value.tostring()
GridView事件大全
using system using system.data using system.configuration using system.collections using system.web using system.web.security using system.web.ui usin...
GridView事件大全
using system using system.data using system.configuration using system.collections using system.web using system.web.security using system.web.ui usin...
GridView事件詳解
rowcommand 在 gridview 控制項中單擊某個按鈕時發生。此事件通常用於在該控制項中單擊某個按鈕時執行某項任務。pageindexchanging 在單擊頁導航按鈕時發生,但在 gridview 控制項執行分頁操作之前。此事件通常用於取消分頁操作。pageindexchanged 在單...