Chris

Chris

  • NA
  • 1
  • 0

Disable dropdown box option

May 2 2007 3:02 PM
Let me preface by admitting I'm a bit of a C# noob.  I'm here learning on the job and need to find a way to disable certain options in a dropdown box we have.  That said, here's the code:

<ASP:DROPDOWNLIST ID="drpAreas" RUNAT=server AUTOPOSTBACK=False></ASP:DROPDOWNLIST>

It's filled from a database with this code:

foreach(DataRowView drv in dvTopics)
{
    if (int.Parse(drv.Row["Category_key"].ToString()) != iCurrKey)
    {
      iCurrKey = int.Parse(drv.Row["Category_Key"].ToString());
      //Add The Parent Level Category
      this.drpAreas.Items.Add(new ListItem("--- " + drv.Row["Name"].ToString() + " ---",drv.Row["area_key"].ToString()));
    }
    else
    {
     //Add a sub area
     this.drpAreas.Items.Add(new ListItem(this.Server.HtmlDecode("&nbsp;&nbsp;&nbsp;&nbsp;") + drv.Row["sub_area"].ToString(),drv.Row["area_key"].ToString()));
    }
}

It creates a box that looks something like this:
--- Heading 1 ---
   Subheading 1-1
   Subheading 1-2
--- Heading 2 ---
   Subheading 2-1
   Subheading 2-2

What I'd love to do is make it so a user can SEE but NOT SELECT any of the headings.  Any ideas?

Thanks!