无法获取TextBox值的网格视图 [英] unable to fetch TextBox values Grid View

查看:78
本文介绍了无法获取TextBox值的网格视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



行更新时,我无法提取文本框值...
请检查以下代码...

TextBox id =(TextBox)GridView1.Rows [e.RowIndex] .FindControl("TextBox1");
TextBox用户名=(TextBox)GridView1.Rows [e.RowIndex] .FindControl("TextBox2");
TextBox密码=(TextBox)GridView1.Rows [e.RowIndex] .FindControl("TextBox3");

Hi,

I am not able extract textbox values while row updating...
Please check below code...

TextBox id =(TextBox) GridView1.Rows[e.RowIndex].FindControl("TextBox1");
TextBox username = (TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox2");
TextBox password = (TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox3");

推荐答案

您必须使用DataKeyNames作为id在网页的.aspx文件中,并使用DataKey查找ID

例如
分配数据键名

< asp:gridview id ="gvEG" runat ="server" autogeneratecolumns ="False" datakeynames ="ID>


在.CS文件中使用

Convert.ToInt64(gvEG.DataKeys [e.RowIndex] .Values [0] .ToString());
you have to use DataKeyNames as id in .aspx file of webpage and use DataKey to find id

eg
Assign datakeyname

<asp:gridview id="gvEG" runat="server" autogeneratecolumns="False" datakeynames="ID>


in .CS file use

Convert.ToInt64(gvEG.DataKeys[e.RowIndex].Values[0].ToString());


这篇关于无法获取TextBox值的网格视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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