Click here to Skip to main content
13,189,324 members (66,011 online)
Rate this:
Please Sign up or sign in to vote.
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 21:05pm
Updated 2-Jan-12 21:27pm
Mehdi Gholam345.3K
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 |
Web01 | 2.8.171016.2 | Last Updated 3 Jan 2012
Copyright © CodeProject, 1999-2017
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