Click here to Skip to main content
15,898,374 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to pass default1.aspx page Gridview data to default2.aspx gridview based on checkbox selected
Posted
Updated 14-Oct-11 23:51pm
v2

1 solution

Hi,

you can pass them in following ways.


pass those ids in querystring
store those ids in session in firstpage use them in second page.


after completion of checkbox selection user clicks submit button right.

in submit button write code just as following
C#
  string qry="";
   foreach(datalistitem fti in datalist1.items)
{
     checkbox cchb=(checkbox)dti.fincontrol("checkbox1");
     if(cchb.checked)
{
      if(qry.length==0)
{
       qry=qry+((Label)dti.findcontrol("Lblid")).Text;
}
else
{
        qry=qry+","+((Label)dti.findcontrol("Lblid")).Text;
}     
}
}

//all ids are stored in qry string with ',' s
Session["ids"]=qry;
response.redirect("default2.aspx?ids="ids);


Her i used datalist control you can use gried also with some changes like grid.rows
you can use either session or query string value in default2.aspx page

in second page you can get related data based on ids

All the Best
 
Share this answer
 
v2

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