Friday, October 21, 2011

How to hide/display item of gridview like button or Image



protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)

    {

         if (e.Row.RowType == DataControlRowType.DataRow)

        {

            // Here Documentname : Is the columan name of gridview

            string docName = DataBinder.Eval(e.Row.DataItem, "Documentname").ToString();



            if (docName.Length == 0)

            {  // Here lnkDetails : is the control embeded in gridview

                ((LinkButton)e.Row.FindControl("lnkDetails")).Visible = false;



            }



        }

    }