开发者

How to set page size of a grid

I have a grid it has to display some 100 rows from a table. I do not want to set any paging or sorting. How to display the grid with out any page size?

If I do not specify any page size then by default it takes ten and after ten if I add any row it throws an error.

<asp:GridView
ID="gvEventMechanic"
runat="server" 
AutoGenerateColumns="False"
AllowPaging="False"
GridLines="None"
BorderWidth="1"
BorderColor="Brown"
AlternatingRowStyle-BackColor="Cyan"
HeaderStyle-BackColor="ActiveCaption"
FooterStyle-BackColor="DimGray"
EnableViewState="true" >

UPDATE

Removed allow paging.

This is the exact error.

Microsoft JScript runtime error:
Sys.WebForms.PageRequestManagerServerErrorException:
The GridView 'gvEventMechanic' fired event PageIndexChanging which wasn't
handled

I have a add button down the grid which will add an empty row to the grid. If no page size is give开发者_JAVA技巧n it automaticaly uses 10 as default and while entering 11 items it gives me an option for > >>. If I click on >> I get the above error.

This is the code for my add button:

DataRow drCurrentRow = null;
drCurrentRow = _dsMechanic.Tables[0].NewRow();
drCurrentRow["Id"] = 0;
drCurrentRow["Description"] = string.Empty;
//Adds new row to the existing row
drCurrentRow["Passive"] = 0;
//Bind the new row with grid 
_dsMechanic.Tables[0].Rows.Add(drCurrentRow);
gvEventMechanic.DataSource = _dsMechanic.Tables[0];
gvEventMechanic.DataBind(); 


Try the AllowPaging="False" but if its not working, please check if there is a skin for Grid View that set the AllowPaging="True".


Get AllowPaging="False" away from your GridView declaration because it is false by default. After that try cleaning and rebuilding your project.

If it does not help, please publish the whole error message and a stack trase. And also more GridView related code if possible. Perhaps you get your error not because of paging at all.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜