Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 select multiple items in checkboxlist n store

Author  Topic 

sheena
Starting Member

45 Posts

Posted - 2007-04-08 : 00:15:35
I have multiple checkboxlist for the hobbies or activities.
I want to know how can i store multiple checkbox selected in the database...

If i select multiple then it gets store only 1 checkbox.
If i select anyone then it select it only.

I have created stored procedure in SQL SERVER 2005 and the application is created in ASP.NET 2005 with C#.
I retrieve data thru sqldatasource and presents in the gridview.

I have tried to write something like this on the submit button click event::

 foreach (ListItem item in CheckBoxList1.Items)
{
if (item.Selected.Equals("READ"))
{
SqlDataSource1.InsertParameters["hobbies"].Name = CheckBoxList1.SelectedItem.Value.ToString();
}
if (item.Selected.Equals("WRITE"))
{
SqlDataSource1.InsertParameters["hobbies"].DefaultValue = CheckBoxList1.SelectedItem.Value.ToString();
}
}
SqlDataSource1.Insert();
GridView1.Visible = true;


Please help me to solve my this problem and if possible please rectify the errors.I m sure that the above code must be wrong as it is not working...In database 1 record is recorded and thenafter in gridview also 1 record is displayed

Thanxs for the reponse in adv.
   

- Advertisement -