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
sushant dongre
NA
1
0
DataBind() does not allow ListItem.Selected property to be set
Feb 27 2006 4:56 AM
when databinding a listbox to a dataset and using the ListItem.Selected property also the SelectedIndex property are never set when user selects the perticular item. so the if(item.selected) is never set true . is there any problem with the databinding because when not using databinding and just using ListBox.add() method it works properly this is the code in page_load:- listbox_project_users.SelectionMode=ListSelectionMode.Multiple; listbox_all_users.SelectionMode=ListSelectionMode.Multiple; conn = new SqlConnection(); conn.ConnectionString = configurationSettings.AppSettings.Get("BepDB"); conn.Open(); cmd=new SqlCommand("SELECT PrjUser.UserID AS UserID,Users.UserName AS Name FROM PrjUser INNER JOIN Users ON PrjUser.UserID=Users.UserID WHERE PrjID=1; SELECT UserID,UserName FROM Users WHERE UserID NOT IN (SELECT UserID FROM PrjUser WHERE PrjID=1);",conn); da=new SqlDataAdapter(cmd); ds=new DataSet("PrjUsers"); da.Fill(ds); listbox_project_users.DataTextField="Name"; listbox_project_users.DataValueField="UserID"; listbox_project_users.DataSource=ds.Tables[0]; listbox_project_users.DataBind(); listbox_all_users.DataTextField="UserName"; listbox_all_users.DataValueField="UserID"; listbox_all_users.DataSource=ds.Tables[1]; listbox_all_users.DataBind(); when user clicks the add button on the page i am supposed to update the database depending on the selected item but the if statement never clears.(always false) the button_click method:- foreach (ListItem item in listbox_all_users.Items) { if(item.Selected) { cmd=new SqlCommand("INSERT INTO PrjUser VALUES (1,5,1,0)",conn); cmd.ExecuteNonQuery(); } } pls give it a thought
Reply
Answers (
0
)
Asp.net with C#
sending mail using MailMessage