>

Wednesday, June 02, 2010

Dynamically add CommandField of type Image to a gridview or any container.

Kindle Wireless Reading Device (6" Display, Global Wireless, Latest Generation)


Dynamically add CommandField of type Image to a grid or any container.

if (!IsPostBack)
{
if (Session["USERTYPE"].ToString() == "S")
{
CommandField ImageCommand = new CommandField();
ImageCommand.ButtonType = ButtonType.Image;
ImageCommand.DeleteImageUrl = "~/images/delete.gif";
ImageCommand.ShowCancelButton = false;
ImageCommand.ShowDeleteButton = true;
GridView1.Columns.Add(ImageCommand);
}
}

Then do the normal

protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{

}



to delete or change as per your requirements.

0 comments: