如何在gridview中获取特定列值 [英] how to get a particular column value in gridview

查看:59
本文介绍了如何在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....


这篇关于如何在gridview中获取特定列值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆