asp.net c#
how to perform list box values in asp.net C# and how to insert list box value from front end to database sql2008 please send the sample coding
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Munesh SharmaPosted Jul 23, 2014, 6:07 AM
{
c.Open();
using (SqlCommand cmd = new SqlCommand("INSERT INTO table (field1, field2) VALUES (@field1, @field2)")
{
foreach (ListItem item in listbox2.Items)
{
cmd.Parameters.Clear();
cmd.Parameters.AddWithValue("@field1", item.Value);
cmd.Parameters.AddWithValue("@field2", item.Text);
cmd.ExecuteNonQuery();
}
}
}