开发者

Hide Image button from some rows in Gridview

开发者 https://www.devze.com 2023-03-24 22:53 出处:网络
I have added an image button in the template field of the gridview. The gridview contains 20 rows. In all the rows, the image button is being added. Now, if i wish to hide the开发者_如何学运维 image b

I have added an image button in the template field of the gridview. The gridview contains 20 rows. In all the rows, the image button is being added. Now, if i wish to hide the开发者_如何学运维 image button from some rows, what should i do?

I cannot remove from the gridview else that would go away from all rows.

Please guide

Let me know for any query.

Thanks!


Make use of RowDataBound Event avaialbe with the GridView where you can hide the control you want for the given row.

void grv_RowDataBound(object sender, GridViewRowEventArgs e)
{
  if (e.Row.RowType == DataControlRowType.DataRow)
  {
      if(condition)
      {
       ImageButton imgBtn= (ImageButton)e.Row.FindControl("mybuttonid");
       imgBtn.Visible = false;
      }
  }
}


In RowDataBound Event:

 if (e.Row.RowType == DataControlRowType.DataRow)
 {
     ((ImageButton)e.Row.FindControl("imgbtnImage")).Visible = false; 
 }
0

精彩评论

暂无评论...
验证码 换一张
取 消