views:

26

answers:

1

Hello Guys,

I am using a checkboxlist which I am populating from the database using Databind(). And i am having Dropdownlist in UpdatePanel to avoid postbacks which is also populated form database. Each Item in dropdownlist-> Associated to Many Items in Checkboxlist. Is there any way I can Make Associated listitems bold(to highlight them) on Dropdown Selected Index Changed Event so that user will know he has to select the highlighted checkboxes for the selected value in dropdownlist? I have tried using the listitem Attributes as well but it's not working. See the code below.

protected void LOSDropDownList_SelectedIndexChanged(object sender, EventArgs e)
    {
        try
        {
            string selectedValue = LOSDropDownList.SelectedValue;
            LOSQuestionsBOReadOnlyList QuestionList = LOSQuestionsBOReadOnlyList.GetLOSQuestionsBOReadOnlyListByLevelOfServiceId(Convert.ToInt32(selectedValue));                                
            if (!selectedValue.Equals(""))
            {
                foreach (ListItem Item in QuestionCheckboxList.Items)
                {
                    Item.Attributes.CssStyle.Clear();
                    if(QuestionList.FirstOrDefault(Val => (Val.ServiceLevelQuestion_ID == int.Parse(Item.Value.ToString()))) == null)
                    {
                        Item.Attributes.CssStyle.Add("font-weight", "bold");
                    }
                    else Item.Attributes.CssStyle.Add("font-weight", "normal");
                }                   
            }
        }
        catch (Exception ex)
        {
            ExceptionPolicy.HandleException(ex, "Event_File_Policy");
        }
    }

Your help will be appreciated

Thanks And Regards,

Chetan

A: 

Try this:

On the SelectedIndexChanged event of dropdownlist:

foreach(ListItem li in chkboxlist.Items)
{
  //If dropdownlist selection matches with chklistbox (or whatever other logic you want)
  if(li.Text == dropdownlist.SelectedText)
  {
    **//Here's how to set it to bold**
    li.Attributes.CssStyle.Add("font-weight", "bold");
  }
}
Sidharth Panwar
No, It's not working
Chetan
What happens when you do the above?
Sidharth Panwar
Thanks Sidharth but It didn't change the font style. I have updated the question with the code Where I am trying to set the attribute. Please suggest.
Chetan