Click here to Skip to main content
15,922,166 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have added a grid view in my asp.net pages which includes checkbox field,and three databound field.
I want to store the entire row upon check box click in the grid view into either session or dataset when button click even is fired. becouse I want to take the selected value from grid view into another page where I can able to show the session value.

[edit]DON'T SHOUT! It is considered rude to use all uppercase (and childish to use all lower case) - OriginalGriff
Posted
Updated 30-Sep-10 5:50am
v2
Comments
Hiren solanki 30-Sep-10 10:35am    
just type all in lower case, it's like shouting feeling.

1 solution

List<T> lst=new List<T>(); // Create List to store Checked Rows values

loop through all rows the gridview  :

ForEach(GridViewRow gRow in GridView1.Rows)
{
    bool checked= ((CheckBox)e.Row.Cells[IndexOfCheckboxField].Controls[0]).Checked;

    if(checked)
   {
      //Create object to set values
      //get values using e.Row.Cells[index].Text and set the object
      //add the object to lst 
   }

}
Session["Data"]=lst;  //Store the lst in Session
 
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