Search code examples
c#datalistitemdatabound

C# Calling edit command in ItemDataBound


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"));
    }
}

Solution

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