gpt4 book ai didi

c# - 更改页面后gridview消失

转载 作者:太空宇宙 更新时间:2023-11-03 15:34:44 24 4
gpt4 key购买 nike

我有一个应该分成页面的 gridview 但问题是当我更改页面时整个 gridview 都消失了我尝试了我在互联网上找到的所有东西但是没有解决方案这里是我的代码

<asp:GridView ID="ExistContents" runat="server" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None"
AllowPaging="true" PageSize="5" OnPageIndexChanging="ExistContents_PageIndexChanging" >
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:BoundField DataField="ContentID" HeaderText="id" />
<asp:ImageField DataImageUrlField="TmpFilename" HeaderText="Image">
<ControlStyle Height="64px" Width="96px" />
</asp:ImageField>
<asp:BoundField DataField="Name" HeaderText="Name" />
<asp:BoundField DataField="Description" HeaderText="Description" />
<asp:BoundField DataField="Type" HeaderText="Type" />
<asp:BoundField DataField="ContentID" HeaderText="id" Visible="false" ShowHeader="false" />
<asp:TemplateField HeaderText="Delete">
<ItemTemplate>
<asp:UpdatePanel runat="server">
<ContentTemplate>
<asp:CheckBox runat="server" ID="ChBox1" OnCheckedChanged="ExistContents_CheckedChanged" AutoPostBack="True"/>
</ContentTemplate>
</asp:UpdatePanel>

</ItemTemplate>
</asp:TemplateField>
</Columns>

<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" CssClass="header"/>
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>

这是事件处理程序

protected void ExistContents_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
ExistContents.PageIndex = e.NewPageIndex;

List<CONTENT> panier;
panier = (List<CONTENT>)Session["PANIER"];
ExistContents.DataSource = panier;
ExistContents.DataBind();
}

最佳答案

您应该处理 PageIndexChanged而是事件。

pageIndexChanging旨在为您提供在执行前取消分页的选项。

关于c# - 更改页面后gridview消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32172363/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com