DataKeyNames

GridView的DataKeyNames属性设为"ID,Name"
GridView1.DataKeyNames = new string[]{ "ID","Name" };

列中LinkButton的CommandName属性设为"Delete"

就可以在GridView1_RowDeleting中写代码:


DataKey key = GridView1.DataKeys[e.RowIndex];
int id = int.Parse(key[0].ToString());//得到id字段值
string name = key[1].ToString();//得到name字段值
posted @ 2010-05-06 12:47  与时俱进  阅读(203)  评论(0编辑  收藏  举报
友情链接:同里老宅院民居客栈