Click here to Skip to main content
11,931,584 members (67,713 online)
Rate this:
Please Sign up or sign in to vote.
See more: ASP.NET string ASP.NET4
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
          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..
Posted 2-Jan-12 22:05pm
Edited 2-Jan-12 22:27pm
Mehdi Gholam292.8K
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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 use Convert.ToString(Request.QueryString("email"));.
This will help you avoid an error when your querystring has no email.

However, nothing will be displayed in the blemail.Text control.
mirzamujib 3-Jan-12 3:25am
Thanks Abhinav,

But where should i give the querystring parameter...
can u plz gime syntax...

thanks again...
Abhinav S 3-Jan-12 3:32am
You dont need to use the query string syntax. Just use Convert.Tostring instead of ToString().
mirzamujib 3-Jan-12 3:42am
Thanks Abhinav,

I tried and its shows me null value in my lblemail (label).
Abhinav S 3-Jan-12 5:26am
So your error is gone.
Now check if you are passing email in the querystring (this is nothing but the URL for the webpage).
Note that query string parameters are case-sensitive.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

grdviewLink.NavigateUrl +="&email=" + Me.GridView1.SelectedRow.Cells(3).Text

Add the field to navigate URL...
Mika Wendelius 3-Jan-12 15:57pm
Pre tags added

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web03 | 2.8.151126.1 | Last Updated 3 Jan 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100