在datalist中使用项模板控件时出现空引用异常 [英] Null reference exception while using item template controls in datalist

查看:47
本文介绍了在datalist中使用项模板控件时出现空引用异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用datalist来显示表中的数据。在每个记录中都有文本框和保存按钮。当用户在文本框中输入数据并单击保存时,应将数据插入到其他表中,该行的id为foriegn键。但是,当我在另一个变量中使用textbox的值时,会发生nullreferrenceexception。我写了以下行来检查文本框的值。

Hi, I have used datalist to display data from the table. In each record there is textbox and save button. When user enter data in textbox and click save, the data should be inserted in other table with the id of that row as foriegn key. But, when I take the value of textbox in another variable, the nullreferrenceexception occurs. I write following line to check the value of textbox.

Label1.Text=((Label)dlProductBasedSales.FindControl("lblIProductId")).Text;



有什么问题?建议解决方案。


What is wrong? Suggest me the solution.

推荐答案

如何在datalist中使用findcontrol! [ ^ ]


这篇关于在datalist中使用项模板控件时出现空引用异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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