Click here to Skip to main content
Rate this: bad
good
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
        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..
Posted 2-Jan-12 22:05pm
Edited 2-Jan-12 22:27pm
Mehdi Gholam253.4K
v2
Rate this: bad
good
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.
  Permalink  
Comments
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
good
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...
  Permalink  
v2
Comments
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 OriginalGriff 350
1 Jochen Arndt 150
2 Richard MacCutchan 135
3 PIEBALDconsult 110
4 Sergey Alexandrovich Kryukov 104
0 OriginalGriff 6,055
1 DamithSL 4,621
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,500
4 Sergey Alexandrovich Kryukov 3,294


Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 3 Jan 2012
Copyright © CodeProject, 1999-2014
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