Click here to Skip to main content
15,068,929 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I am working with GRID VIEW ,

1. There is a drop down to select items, when the user selected item the grid view will items will change.

2. In grid view there are chekboxes, when the user checked the items they should store in DB.

3. So how to call the chekbox selected VALUES to store in DB. ?

Please give me the example.
Posted
Updated 2-Sep-11 20:34pm
v2

What you need to do is iterate over the checked check boxes and then perform actions only on the selected rows.

Have a look at this[^] example. Its in VB, but will give you the general concept and should surely help you out.
   
Comments
Uday P.Singh 3-Sep-11 2:28am
   
nice link my 5!
Abhinav S 3-Sep-11 2:30am
   
Thanks Uday.
1) if you don't want to change value at dropdown value select than set the autopostback=false of dropdown box

2) for check box , store unique id of DB in on field or in hidden field,
than in rowcommand event iterate
C#
foreach (GridViewRow grdRow in grd_name.Rows)
{
 CheckBox chk = (CheckBox)grdRow.FindControl("chk_checkbox");
 HiddenField hdn= (HiddenField)grdRow.FindControl("hiddenfiled");

 if (chk != null){
                        strids += hdn ",";
                        strstatus += Convert.ToInt32(chk.Checked).ToString() + ",";
           }
}


now you get the id string like 1,2,3,4,5 and
check box value as per id like true,false,false,true,false
etc.....

i think now u can understand what am i trying to say....
Thanks,,
   

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