0

i have a dropdownlist of employees types ( Project Manager, developer , qa etc ). and a checkboxList of tasks that need to be assigned to each employee type. but for developer , there will be only one task at a time. i.e a person will be able to assign only one task to a developer at a time. if he selects a second one, the first choice should be unchecked. for other employees with multiple tasks , its working fine. but how to put a check in developer case ?

i have used below code but it is creating problem on edit , update. also when i select one task for a developer , all other checkbox get disabled and i cannot change the task.

 If dt.Rows.Count > 0 Then
        Dim developer As Boolean = Convert.ToBoolean(dt.Rows(0)(0).ToString())
        If developer Then
            For Each li As ListItem In cblTaskType.Items
                If Not li.Value = employeeType Then
                    li.Selected = False
                    li.Enabled = False
                End If

            Next
4
  • 3
    Any code to share with us ? Commented Mar 30, 2015 at 8:10
  • You can do this by Client side code using Javascript or JQuery. Commented Mar 30, 2015 at 8:26
  • thanks @Selva but I want to do this in VB.net . Commented Mar 30, 2015 at 8:36
  • 1
    well this stackoverflow.com/questions/3655068/… worked for me . thanks to everyone Commented Mar 30, 2015 at 9:11

2 Answers 2

2

you can use below code .. Use SelectedIndexChanged event of checkedListBox1 .

private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e)
           {
               int iSelectedIndex = checkedListBox1.SelectedIndex;
               if (iSelectedIndex == -1)
                   return;
               for (int iIndex = 0; iIndex < checkedListBox1.Items.Count; iIndex++)
                   checkedListBox1.SetItemCheckState(iIndex, CheckState.Unchecked);
               checkedListBox1.SetItemCheckState(iSelectedIndex, CheckState.Checked);
           }

you can also refer this Link

Sign up to request clarification or add additional context in comments.

Comments

0

I had the same problem... I changed it to a radiobutton list and joined all the radio buttons to the same group (in properties).

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.