2

I'm currently struggling to find the code which I need to call in the if statement in order to find the edit event of a data list.

I am trying to create a blank drop down item on an existing Drop Down List.

Any help would be great! Thanks!

protected void DL_Items_ItemDataBound(object sender, DataListItemEventArgs e)
{
    if ( )
    {
        DropDownList DDL_Designers = (DropDownList)e.Item.FindControl("DDL_Designers");
        DDL_Designers.Items.Insert(0, new ListItem("N/A", "0"));
    }
}
Akram Shahda
  • 14,655
  • 4
  • 45
  • 65
Callum
  • 3,221
  • 3
  • 19
  • 18

2 Answers2

3

Try if (e.Item.ItemType == ListItemType.EditItem)

Dave Anderson
  • 11,836
  • 3
  • 58
  • 79
Liam
  • 9,725
  • 39
  • 111
  • 209
2
if (e.Item.ItemType == ListItemType.EditItem)
Akram Shahda
  • 14,655
  • 4
  • 45
  • 65
Massimiliano Peluso
  • 26,379
  • 6
  • 61
  • 70