Click here to Skip to main content
15,886,761 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hai,


I am using gridview.It is having 20 rows.I want to pass the count value into next .aspx page.How can i do this.By using session it is ok?I tried by using session.But it is not populating the value.

Source page:

Session["Incidentgv"] = grdEmployee.Rows.Count.ToString();


Target page:

string incident=(string) Session["Incidentgv"];



Plz help me.


Thanks in advance
Posted
Updated 28-Dec-13 23:37pm
v3
Comments
Jignesh Khant 23-Dec-13 2:15am    
You want to populate row number or grid values?
Member 10234093 23-Dec-13 2:20am    
total number of rows
thatraja 23-Dec-13 2:17am    
what's the error?
Member 10234093 23-Dec-13 2:20am    
Not passing the total rows count value (ie) 20 into other .aspx page.
thatraja 23-Dec-13 2:21am    
Debug when you assign the value to session & make sure the count value there

For getting number of rows u can use
C#
grdEmployee.Rows.Count;


For passing this value to next page u can use query string as follows


Response.Redirect("page2.aspx?Count=value");


U can retrieve this value at page 2 as

String value = Request.QueryString["Count"]
 
Share this answer
 
string incident = Session["Incidentgv"].ToString();
 
Share this answer
 
Before this line of code check if session is null or empty

C#
if(session["Incidentgv"]!=null)
{//If session doesn't contain any value then controll will not enter here.
  string incident=(string) Session["Incidentgv"];
}


If session is null then you may making it null some where else...
 
Share this answer
 
hi make sure that you are assigning the session value after the databind method.

grdEmployee.DataBind();
C#
Session["Incidentgv"] = grdEmployee.Rows.Count.ToString();
 
Share this answer
 
Session is OK and code looks correct. Have you tried to debug program?

For further information, please see:
ASP.NET Session State Overview[^]
How to: Save Values in Session State[^]
How to: Read Values from Session State[^]
ASP.NET Session Helper (Scope, Categories)[^]
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900