访问的GridView细胞值 [英] Accessing GridView Cells Value

查看:109
本文介绍了访问的GridView细胞值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图访​​问的第一个单元格的整数值,但我得到这个错误:


  

无法转换类型'System.Web.UI.WebControls.DataControlFieldCell对象键入'System.IConvertible。


我已经存储在该单元格的值是810像一个ID

我的code

  INT身份识别码= Convert.ToInt32(GridView1.Rows [rowIndex位置] .Cells [0]);


解决方案

细胞[0] 返回 DataControlFieldCell 对象,而不是单元格的值。结果
使用电池的文本属性。

I am trying to access the integer value of the first cell but I'm getting this error:

Unable to cast object of type 'System.Web.UI.WebControls.DataControlFieldCell' to type 'System.IConvertible'.

And the value i have stored in that cell is an ID like 810

My Code

int myID = Convert.ToInt32(GridView1.Rows[rowIndex].Cells[0]);

解决方案

Cells[0] returns a DataControlFieldCell object, not the cell's value.
Use the cell's Text property.

这篇关于访问的GridView细胞值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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