Click here to Skip to main content
15,885,668 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hello

how use image button in grid view for show enable or disable status in asp.net with picture when click on image button change status and save to database ?
Posted
Comments
Sunasara Imdadhusen 20-Jun-13 8:58am    
What you tried??
tree1371 20-Jun-13 15:13pm    
i use this code for set image:

grdUsers.DataSource = ds;
grdUsers.DataBind();
foreach (GridViewRow row in grdUsers.Rows)
{
ImageButton img = (ImageButton)row.FindControl("EnabledImgBtn");
if (!DBNull.Value.Equals(img.CommandArgument))
{
if (img.CommandArgument == true.ToString())
{
img.ImageUrl = "~/Admin/img/enable.png";
}
else
{
img.ImageUrl = "~/Admin/img/disable.png";

}
}
}

how i create event click for change status for imagebutton?

1 solution

Try this,

Put in event img_Click()

C#
protected void img_Click(object sender, ImageClickEventArgs e)
{
    if(img.ImageUrl == "~/Admin/img/enable.png")
    {
        status = enable;
    }
    else
    {
        status = disable;
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900