无法进入Gridview的下一页

编程入门 行业动态 更新时间:2024-10-26 08:23:10
本文介绍了无法进入Gridview的下一页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

亲爱的所有 我使用gridview它显示结果但是当我点击下一页时gridview消失了。我的代码如下 < asp:GridView ID =Grid1runat =serverAllowPaging =TrueAutoGenerateColumns =FalseBackColor =LightGoldenrodYellow BorderColor =TanBorderWidth =1pxCellPadding =2ForeColor =BlackOnPageIndexChanging =Grid1_PageIndexChangingPageSize =5> < alternatingrowstyle backcolor =PaleGoldenrod> ; < columns> < asp:BoundField DataField =RnoHeaderText =R.No> < itemstyle horizo​​ntalalign =Center> < asp:BoundField DataField =NameHeaderText =Name/> < asp:BoundField DataField =FNameHeaderText =FName/> < asp:BoundField DataField =studentClassHeaderText =Class> < itemstyle horizo​​ntalalign =Center> < asp:BoundField DataField =EnglishHeaderText =English> < itemstyle horizo​​ntalalign =Center> < asp:BoundField DataField =UrduHeaderText =Urdu> < itemstyle horizo​​ntalalign =Center> < asp:BoundField DataField =PhysicsHeaderText =Physics> < itemstyle horizo​​ntalalign =Center> < asp:BoundField DataField =ChemistryHeaderText =Chemistry> < itemstyle horizo​​ntalalign =Center> < asp:BoundField DataField =MathHeaderText =Maths> < itemstyle horizo​​ntalalign =Center> < asp:BoundField DataField =TotalHeaderText =Toal> < HeaderStyle Horizo​​ntalAlign =Center/> < asp:BoundField DataField =PercentageDataFormatString ={0:0.00}HeaderText =Percentage> < itemstyle horizo​​ntalalign =Center> < footerstyle backcolor =Tan> < HeaderStyle BackColor =TanFont-Bold =True/> < pagerstyle backcolor =PaleGoldenrodforecolor =DarkSlateBluehorizo​​ntalalign =Center> < SelectedRowStyle BackColor =DarkSlateBlueForeColor =GhostWhite/> < sortedascendingcellstyle backcolor =#FAFAE7> < sortedascendingheaderstyle backcolor =#DAC09E> < sorteddescendingcellstyle backcolor =#E1DB9C > < sorteddescendingheaderstyle backcolor =#C2A47B> 我怎么用以下的下一页活动 protected void Grid1_PageIndexChanging(object sender,GridViewPageEventArgs e) { Grid1.PageIndex = e.NewPageIndex; Grid1.DataBind(); } 请帮帮我

Dear All I am using the gridview it displays the result but when I hit the next page the gridview disappear. my code is as follows <asp:GridView ID="Grid1" runat="server" AllowPaging="True" AutoGenerateColumns="False" BackColor="LightGoldenrodYellow" BorderColor="Tan" BorderWidth="1px" CellPadding="2" ForeColor="Black" OnPageIndexChanging="Grid1_PageIndexChanging" PageSize="5"> <alternatingrowstyle backcolor="PaleGoldenrod"> <columns> <asp:BoundField DataField="Rno" HeaderText="R.No"> <itemstyle horizontalalign="Center"> <asp:BoundField DataField="Name" HeaderText="Name" /> <asp:BoundField DataField="FName" HeaderText="FName" /> <asp:BoundField DataField="studentClass" HeaderText="Class"> <itemstyle horizontalalign="Center"> <asp:BoundField DataField="English" HeaderText="English"> <itemstyle horizontalalign="Center"> <asp:BoundField DataField="Urdu" HeaderText="Urdu"> <itemstyle horizontalalign="Center"> <asp:BoundField DataField="Physics" HeaderText="Physics"> <itemstyle horizontalalign="Center"> <asp:BoundField DataField="Chemistry" HeaderText="Chemistry"> <itemstyle horizontalalign="Center"> <asp:BoundField DataField="Math" HeaderText="Maths"> <itemstyle horizontalalign="Center"> <asp:BoundField DataField="Total" HeaderText="Toal"> <HeaderStyle HorizontalAlign="Center" /> <asp:BoundField DataField="Percentage" DataFormatString="{0:0.00}" HeaderText="Percentage"> <itemstyle horizontalalign="Center"> <footerstyle backcolor="Tan"> <HeaderStyle BackColor="Tan" Font-Bold="True" /> <pagerstyle backcolor="PaleGoldenrod" forecolor="DarkSlateBlue" horizontalalign="Center"> <SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" /> <sortedascendingcellstyle backcolor="#FAFAE7"> <sortedascendingheaderstyle backcolor="#DAC09E"> <sorteddescendingcellstyle backcolor="#E1DB9C"> <sorteddescendingheaderstyle backcolor="#C2A47B"> How ever I am using the following next page event protected void Grid1_PageIndexChanging(object sender, GridViewPageEventArgs e) { Grid1.PageIndex = e.NewPageIndex; Grid1.DataBind(); } Please help me

推荐答案

因为你没有使用数据源控件 [ ^ ],你没有使用新的.NET 4.5模型绑定功能 [ ^ ],你需要为每个网格提供一个 DataSource 页面索引更改的时间。 通常,代码看起来像这样: Since you're not using a data source control[^], and you're not using the new .NET 4.5 model binding features[^], you need to provide the grid with a DataSource every time the page index changes. Typically, the code would look something like this: protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindGrid(); } } protected void Grid1_PageIndexChanging(object sender, GridViewPageEventArgs e) { Grid1.PageIndex = e.NewPageIndex; BindGrid(); } private void BindGrid() { Grid1.DataSource = LoadSomeDataHere(); Grid1.DataBind(); }

更多推荐

无法进入Gridview的下一页

本文发布于:2023-06-13 05:22:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/674865.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:下一页   Gridview

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!