Click here to Skip to main content
11,806,026 members (60,950 online)
Rate this: bad
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 21:05pm
Edited 2-Jan-12 21:27pm
Mehdi Gholam288.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 at 3-Jan-12 3:25am
Thanks Abhinav,

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

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

I tried and its shows me null value in my lblemail (label).
Abhinav S at 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 at 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
0 Richard Deeming 225
1 OriginalGriff 215
2 Sergey Alexandrovich Kryukov 170
3 Abhinav S 120
4 ppolymorphe 115
0 OriginalGriff 3,330
1 Maciej Los 1,990
2 KrunalRohit 1,907
3 CPallini 1,905
4 Richard MacCutchan 1,227

Advertise | Privacy | Mobile
Web02 | 2.8.151002.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