如何在asp.net的GridView中按列名获取索引值 [英] How to get the index value by column name in GridView in asp.net

查看:66
本文介绍了如何在asp.net的GridView中按列名获取索引值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



i我在asp.net中有一个gridview

现在我希望索引值按列名

如何这样做。



例如


i am having a gridview in asp.net
and now I want the index value by the column name
How to do it.

for example

productid   |  productname   |    Productcode  | edit  |  delete





当我写编辑时,它应该给我它的索引值[3]



这是可能的????



i尝试这样做



when i write Edit it should give me its index value [3]

is this possible????

i tries to do this

protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
      {
          string columnValue = ((Label)e.Row.FindControl("imgEdit")).Text;
      }



但是它给了我错误

对象引用未设置为对象的实例











请帮助

问候


but it gives me error
"object reference not set to an instance of an object"





please help
Regards

推荐答案

看看这里: Gridview - 如何通过它的列名而不是单元格索引查找列[ ^ ]


这篇关于如何在asp.net的GridView中按列名获取索引值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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