如何在gridview中获取特定列值

问题描述:

我有一个gridview,我想从中删除一行。我想删除UID(我的表中的主要字段)的整行。存储过程只对我们单击的行进行del,即获取UID列的值并将其传递给存储过程。我的问题是如何获得列值。我正在使用

i have a gridview and i want to delete a row from it . i want to delete a whole row on account of UID(a primary field in my table). the stored procedure only del the row we click i.e get the value of UID column and passes that to stored proc. my question is how to get the column value. i m using

obj.UID = Convert.ToInt32(GridView1.SelectedRow.Cells[1].Text);
        obj.Datadelete();



其中datadelete()是我删除行的方法,但实际上它不起作用。为什么?我不想使用datakeynames prop。


where datadelete() is my method to delete the row but actually it is not working . why? i dont want to use datakeynames prop.

obj.UID = Convert.ToInt32(grid_Pump.DataKeys [e.RowIndex] [ID]。ToString() );







[ID]是db table的列名





在gridview中设置DataKeyNames =ID之前





我认为这有助于你
obj.UID = Convert.ToInt32(grid_Pump.DataKeys[e.RowIndex]["ID"].ToString());



["ID"] is the column name of db table


before it set DataKeyNames="ID" in gridview


I think it helps u


请在你的页面中选择gridview并转到属性......因为你有列集合转到那个选项并删除你的任何你想删除...如果你想插入更多的列然后插入他们的....
please select the gridview in ur page and go to the properties... in that u have columns collection go to that option and delete what ever u want to delete... if u wnat to insert some more column then insert their....