selection via checkboxlist in gridview

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mercea
    New Member
    • Aug 2007
    • 35

    selection via checkboxlist in gridview

    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
  • mercea
    New Member
    • Aug 2007
    • 35

    #2
    Saving Selected Option From A Checkboxlist To A Gridview

    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
    Code:
      protected void Button1_Click(object sender, EventArgs e)
        {
            
            Response.Redirect("Direction2.aspx");
            foreach ( GridViewRow row in GridView1.Rows) 
            {
                CheckBoxList checkboxlist = (CheckBoxList)row.FindControl("chklist");
                if (checkboxlist != null  )
                {
                    foreach (ListItem litem in checkboxlist.Items)
                    {
                        if (litem.Selected)
                        {
                          // THIS IS WHERE THE PROBLEM IS!
                        } 
                    }
                }
            }
        }
    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!

    Comment

    • kenobewan
      Recognized Expert Specialist
      • Dec 2006
      • 4871

      #3
      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.

      Comment

      Working...