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
Loading
SreekanthPosted Oct 9, 2009, 7:15 AM
Pankaj SinghPosted Oct 9, 2009, 7:05 AM
I have no cell index problem. I know well index will start from 0..
[0]
[1]
[2]...
Pankaj
Pankaj SinghPosted Oct 9, 2009, 6:59 AM
This code (e.Item.Cells[4].Visible = false;) is not working on both event.
GridView1_DataBound and GridView1_RowDataBound.
Pankaj
Rajeswari nathanPosted Oct 9, 2009, 6:57 AM
I think you have the cell index problem. Can you check how many cells are there means..
index will start from 0..
[0]
[1]
[3]
Or Give me clear error message...
SreekanthPosted Oct 9, 2009, 6:51 AM
Pankaj SinghPosted Oct 9, 2009, 6:37 AM
I think you should check this code(e.Row[4].Visible = false; ) does not work on DataBound_event.
Pankaj
Roei BarPosted Oct 9, 2009, 6:32 AM
use
e.Row[4].Visible = false;
Pankaj SinghPosted Oct 9, 2009, 6:08 AM
I have also use below code, but it also generate error.
My code::
protected void GridView1_DataBound(object sender, EventArgs e)
{
GridView1.Columns[4].Visible = false; // Error on this Line
}
Error::
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Help me !
Pankaj
Roei BarPosted Oct 9, 2009, 6:00 AM
its the column that you hide not the cell
its a column per row on Item_DataBound event