What event is executed before a GridVIew is loaded?

brgdotnet
brgdotnet used Ask the Experts™
on
Hello, I have a GridView control with several columns. One of the columns lists a clients purchases for the month. In another column their is an image of a pencil. If someone clicks on the pencil, a secondary grid will be displayed with Data.

Before the GridView displays to the screen, I need to hid the pencile icon in those rows where the cients purchase for the month is less than a certain amount.

So here is my question. Which event for the GridVIew is executed before the GridVIew is rendered to the screen? Because that is where i need to hide the pencil icon if no data is available.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
Use the RowDataBound event.
Here are some examples from a page :


 protected void grid1_RowDataBound(object sender, GridViewRowEventArgs e)
  {

    if (grid1.EditIndex > -1) // in edit mode
    {
      e.Row.Cells[1].Visible = false;
      e.Row.Cells[4].Width = 140;
      return;
    }
   
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
      if ((DataBinder.Eval(e.Row.DataItem, "Link1")).ToString().Contains("www") || (DataBinder.Eval(e.Row.DataItem, "Link1")).ToString().Contains("http"))
      {
        Label link1 = (Label)e.Row.FindControl("lblLink1");


 if ((DataBinder.Eval(e.Row.DataItem, "Link3")).ToString().Length < 1)
      {
        Label link3 = (Label)e.Row.FindControl("lblLink3");
        link3.Visible = false;
      }
Hi,


In a gridview rowdatabound event u can able to hide pencil icon.
First u can find the image/link of pencil icon using

if (e.Row.RowType == DataControlRowType.DataRow)
    {
      Link Pencil = (Link )e.Row.FindControl("LnkPencil");
     //Here check if there is data available and based on that hide the pencil icon
     pencil.visible= false.
     
    }
brgdotnetcontractor

Author

Commented:
Thank you

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial