TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
romasha ali
NA
94
38.3k
ask about checkboxlist
May 7 2013 6:22 PM
i want to store checked items of check box list in database and i got the code but it did not work when i run this code it does not show items in database column rather than it shows "checkbox.DataValueField" in database..code snippet is given below...
kindly help me ...
public partial class courses : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
protected void Page_Load(object sender, EventArgs e)
{ }
protected void SqlDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{ string interests = string.Empty;
foreach (ListItem item in this.checkbox.Items)
if (item.Selected)
{
interests += item.Text;
SqlCommand cmd = new SqlCommand("Insert into tbl3(courseId) values('" + interests + "')", con); //Write Your Query to insert into database table
con.Open();
int iCount = cmd.ExecuteNonQuery();
con.Close();
}
}
}
Reply
Answers (
3
)
Calling Stored Procedure from MVC3 using Entity Framework
how to handle application_error in global.asax with example