Callum
Callum

Reputation: 3381

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

Upvotes: 2

Views: 916

Answers (2)

Liam
Liam

Reputation: 9855

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

Upvotes: 3

Massimiliano Peluso
Massimiliano Peluso

Reputation: 26727

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

Upvotes: 2

Related Questions