protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e) { if (e.CommandName == "SetAsMainImage" || e.CommandName == "DeleteImage" || e.CommandName == "ViewImage" || e.CommandName == "SaveImage" || e.CommandName == "CancelEditImage" || e.CommandName == "EditImage") { LinkButton lnkDelete = e.Item.FindControl("lnkDelete") as LinkButton; HiddenField hdnImageID = e.Item.FindControl("hdnImageID") as HiddenField; int imageID = Convert.ToInt32(hdnImageID.Value); ProviderDAC dac = new ProviderDAC(); ProviderBFC bfc = new ProviderBFC(); Label lblImageDescription = e.Item.FindControl("lblImageDescription") as Label; Label lblImageTitle = e.Item.FindControl("lblImageTitle") as Label; TextBox txtImageTitle = e.Item.FindControl("txtImageTitle") as TextBox; TextBox ckImageDescription = e.Item.FindControl("txtImageDescription") as TextBox; HiddenField hdnFilesize = e.Item.FindControl("hdnFilesize") as HiddenField; if (e.CommandName == "DeleteImage") { string imageVirtualPath = ""; string imageThumbVirtualPath = ""; bfc.DeleteActivityImage(ActivityID, imageID, Convert.ToInt32(hdnFilesize.Value), out imageThumbVirtualPath, out imageVirtualPath); Refresh(); } else if (e.CommandName == "SetAsMainImage") { dac.UpdateActivityPrimaryImage(ActivityID, imageID); Refresh(); foreach (DataListItem item in DataList1.Items) { SetDataListItemMode(item, true); } } } }