Pankaj Singh

Pankaj Singh

  • NA
  • 97
  • 0

Hide Column in Gridview

Oct 9 2009 5:56 AM
Hi,

Note:: It display an error when Allow paging is true and page size is 10. In normal case when Allow Paging is false, there is no error.

My Code of Pageindexing::

protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        fillgrid(); // function to bind data
    }



I am using below code to hide a column in Gridview. Gridview have one template field(Checkbox) and multiple coulmns. And Auto generated field property is true,remember that there is no bound field.But it display an error.

My code::

      protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
   
      {
 
      e.Row.Cells[4].Visible =false;//error generated on this line
 
      }


Error::

Specified argument was out of the range of valid values.
Parameter name: index

Please help me..

Thanks !

Pankaj


Answers (9)