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
Gabriel olayinka
NA
119
4.7k
Checking and unchecking a checklistbox base on combo values
Apr 1 2018 4:42 AM
i and having a combo box which contain a valueMember for each item in the combo box.....
i am also having a checklist box which also contain some item ...... what i want to do is to check and uncheck the checklistbox base on the selectedValue of the combobox....
here is my code
int
STAFF_IDs = (
int
)txtTeacher.SelectedValue;
con.Open();
SqlDataAdapter ds1 =
new
SqlDataAdapter(
"select * FROM SUBJECT_STAFF where STAFF_ID= '"
+ STAFF_IDs +
"' "
, con);
DataTable dt1 =
new
DataTable();
ds1.Fill(dt1);
if
(dt1 !=
null
&& dt1.Rows.Count > 0)
{
for
(
int
i = 0; i < checkedListBox1.Items.Count; i++)
{
for
(
int
k =0; i< dt1.Rows.Count; i++)
{
checkedListBox1.SetItemCheckState(i, (STAFF_ID == Convert.ToInt32(dt1.Rows[k][
"STAFF_ID"
]) ? CheckState.Checked : CheckState.Unchecked));
} }
//end for
}
//end if
the problem i am having is that the checklistbox is not checking the appropriate items in the checklistbox ... again i'm having problem saving all the checked item to the database at once
(NOTE: the purpose of the code is to have a combo box that contain staff name...... and a checklistbox that contain the list of subject..... then i want to assign subjects to staffs from the checklistbox..... again whenever a staff is selected from the combobox, i want the subject that has been assigned to the particular staff be checked on the checklistbox)
Reply
Answers (
1
)
How to Connect MySQL in Asp.net MVC
c# orderby wrong ordering