QueryString errr:对象引用未设置为对象的实例 [英] QueryString errr: Object reference not set to an instance of an object
本文介绍了QueryString errr:对象引用未设置为对象的实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我想将gridview单元格值从一页转移到另一页.在这里,我使用了查询字符串,但震惊了它在某些字段中的工作,而在其他字段(gridview单元格值)中却无效.
我使用以下语法的具有gridview的页面:
Hello everybody,
I want to transfer gridview cells values from one page to another. Here I used query string but to shock its working for some fields and for other fields(gridview cell values) its not working.
The page which has gridview I used this syntax:
Public ReadOnly Property email() As String
Get
Return GridView1.SelectedRow.Cells(3).Text
End Get
End Property
我要使用这些值的页面,我使用了这种语法
The page where i want to use those values I used this syntax
lblemail.Text = Request.QueryString("email").ToString
Error: Object reference not set to an instance of an object
感谢您的帮助..
Thanks for your help..
推荐答案
blemail.Text = Request.QueryString("email").ToString
确保您具有名称为email的querystring参数.
这似乎为null,并将null转换为字符串会引发错误.
要消除该错误,可以使用Convert.ToString(Request.QueryString("email"));
.
当您的查询字符串没有电子邮件时,这将帮助您避免错误.
但是,blemail.Text
控件中将不会显示任何内容.
blemail.Text = Request.QueryString("email").ToString
Ensure that you have a querystring parameter with the name email.
This appears to be null and converting a null to a string is throwing the error.
To remove the error, you can useConvert.ToString(Request.QueryString("email"));
.
This will help you avoid an error when your querystring has no email.
However, nothing will be displayed in theblemail.Text
control.
grdviewLink.NavigateUrl +="&email=" + Me.GridView1.SelectedRow.Cells(3).Text
添加字段以浏览URL ...
Add the field to navigate URL...
这篇关于QueryString errr:对象引用未设置为对象的实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文