469,133 Members | 1,473 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,133 developers. It's quick & easy.

selection via checkboxlist in gridview

35
hi all,

i have a grid view and i have inserted a checboxlist template with 5checkboxes per row into the gridview. i want the user to be able to select an option (A-E) and that selected option be saved somehow because later on, the selected option will be compared with values from another table. this is possible right?

thanks
Sep 17 '07 #1
2 1780
mercea
35
hi all,
i have a checxboxlist in my gridview. i want the user to tick an option and the ticked option to be saved to my database. i have gone this far
Expand|Select|Wrap|Line Numbers
  1.   protected void Button1_Click(object sender, EventArgs e)
  2.     {
  3.  
  4.         Response.Redirect("Direction2.aspx");
  5.         foreach ( GridViewRow row in GridView1.Rows) 
  6.         {
  7.             CheckBoxList checkboxlist = (CheckBoxList)row.FindControl("chklist");
  8.             if (checkboxlist != null  )
  9.             {
  10.                 foreach (ListItem litem in checkboxlist.Items)
  11.                 {
  12.                     if (litem.Selected)
  13.                     {
  14.                       // THIS IS WHERE THE PROBLEM IS!
  15.                     } 
  16.                 }
  17.             }
  18.         }
  19.     }
  20.  
What code do i use to save the selected items to my database?
when i created my table in my database i did not include a checkboxlist column. i created my table using visual studio and i dont know how to include a checkboxlist in the table.

thanks guys!
Sep 25 '07 #2
kenobewan
4,871 Expert 4TB
You really need to learn the basics about databases. Why would you need a checkboxlist in your database when you are just going to insert the value? Take your values, connect to your database and insert or update them using sql.
Sep 25 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Jensen bredal | last post: by
reply views Thread by Jeppe Jespersen | last post: by
reply views Thread by avital | last post: by
6 posts views Thread by dbuchanan | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.