在Gridview控件上查找文本框 [英] Finding Textboxes on Gridview control

查看:101
本文介绍了在Gridview控件上查找文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我想从放置在gridview上的文本框中捕获数据,所以我很想让我像
那样写
字符串stcustid =((TextBox)(Gridview1.FooterRow.FindControl("TxtCustId"))).Text;

我遇到类似
的错误
对象引用未设置为对象的实例.
请解决此错误
谢谢

解决方案



您应该使用一些防弹解决方案.检查我以前的 answer [ Ra选择器类 [ 还要确保在调用时控件已可用(已创建).对于eaxample,如果尝试在preinit上调用它,则尚未创建控件. gridView.Rows [j] .Cells [i] .FindControl("txtbxID");



记住要遍历或给出i和j的正确值

Hi
i want capture data from the textbox that is placed on the gridview so i am tring to get that i written like

string stcustid= ((TextBox)(Gridview1.FooterRow.FindControl("TxtCustId"))).Text;

i am getting error like

Object reference not set to an instance of an object.
please solve this error
thank you

解决方案

Hi,

You should use some bullet proof solution. Check my previous
answer[^] for similar problem...

Ra Selector class[^] is great thing to find/get controls on server side...


Most likely is that the control id is misspeled (case sensitivity also).Check piece by piece in debug.
Gridview1.FooterRow is not null and then Gridview1.FooterRow.FindControl("TxtCustId")) is not null. Based on that please see what is wrong.
Also make sure the control is available at the time of calling (is created). For eaxample if you try to call it on preinit the control is not created yet.


System.Web.UI.WebControls.TextBox txtBxText = (System.Web.UI.WebControls.TextBox)gridView.Rows[j].Cells[i].FindControl("txtbxID");



Remember to loop through or give correct value of i and j


这篇关于在Gridview控件上查找文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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