gridview 相关问题

Gridview是用于显示和操作来自各种数据源的数据的控件。

使用jquery事件处理程序在内容页面中未触发Gridview分页

我的内容页面中有 5 个 jquery 事件处理程序以及一个允许 Paging=true 的简单 gridview。这导致回发中的 __EVENTTARGET="," 和 OnPageindexChanging 未被触发。我

回答 1 投票 0

Gridview 分页无法正常工作

我有一个搜索页面。在列表中显示搜索结果。 当我从页码中选择另一页时,搜索结果消失并显示列表,就像页面刷新一样。 什么...

回答 2 投票 0

如何在代码中实现网格视图分页

我正在使用带有 C# 的 ASP.net Web 应用程序。在我的网络应用程序中,我有一个带有数据网格视图的网页。 我正在使用此方法将数据绑定到数据网格视图 公共无效 fillGridByALLBDetails() ...

回答 3 投票 0

GridView 分页无法正常工作

我正在尝试使用GridView进行分页, 我已经添加了 GridView 的 PageIndexChanging 方法, 但第二页返回一个空页。 我这段代码做错了什么? 受保护...

回答 2 投票 0

通过gridview与eval绑定数据的排序和分页结果

大家好,我的问题是数据是从 sql 检索的,并显示在标签中,但一次我无法分隔数据行,所有数据都显示在一行中,请帮忙 大家好,我的问题是数据是从 sql 检索的,并显示在标签中,但一次我无法将所有数据中的数据行分开,所有数据都显示在一行中,请帮忙 <asp:GridView ID="grid_advertise_2" runat="server" AllowPaging="True" AutoGenerateColumns="False" GridLines="None" OnPageIndexChanging="GridView2_PageIndexChanging" PageSize="1" ShowHeader="False" OnSelectedIndexChanged="GridView2_SelectedIndexChanged"> <Columns> <asp:TemplateField> <ItemTemplate> <tr> <td id="advertise_2"> <asp:Label ID="lbl_advertise_2" runat="server" Font-Names="Tahoma" Font-Size="12pt" ForeColor="black" Text='<%# Bind("TitleEn") %>'/> </td> </tr> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> 在服务器代码中 protected void Page_Load(object sender, EventArgs e) { string Path = "Article.aspx"; Session.Add("Path", Path.ToString()); if (!IsPostBack) { this.BindGridadvertise1(); this.BindGridadvertise2(); } } private void BindGridadvertise1() { myConnection c = new myConnection(); SqlDataAdapter da = new SqlDataAdapter("select * from TblArticleWishka where ID >= 0 ", c.Cnn); DataSet ds = new DataSet(); da.Fill(ds); grid_advertise_1.DataSource = ds.Tables[0]; grid_advertise_1.DataBind(); } 大家好,我做到了,我通过创建新的销售并给他们 cssclass 来做到这一点` 整数 j = 0; protected void grid_advertise_1_RowDataBound(object sender, GridViewRowEventArgs e) { if (j<=1) { myConnection c = new myConnection(); SqlDataAdapter da = new SqlDataAdapter("select * from TblArticleWishka where ID>=0 ", c.Cnn); DataSet ds = new DataSet(); da.Fill(ds); int i = 1; foreach (DataRow dr in ds.Tables[0].Rows) { i++; TableCell a = new TableCell(); a.CssClass = "advertise_1_" + i + ""; a.Text = (string)dr["TitleEn"]; e.Row.Cells.Add(a); a.DataBind(); } j++; } }`

回答 1 投票 0

Gridview 分页 ASP.NET,在 Gridview 之外使用分页器面板

这是我第一次使用ASP.NET开发网站。 我想在具有分页功能的 GridView 中显示数据库中的数据,我可以使用 OnPageIndexChanging="

回答 1 投票 0

Gridview 复选框在分页给出错误时保持状态

我的网格视图有问题 从一页移动到另一页时出现错误 它不会保留分页上的复选框状态 KeepChecks 出现错误 错误信息 索引...

回答 1 投票 0

向我的 ASP.NET GridView 添加分页

我必须显示并提取100k+记录表。 我正在使用 GridView,但它没有显示数据,因为发生了内存异常。 所以我想将分页系统添加到我的 GridView 中。我尝试了各种教程...

回答 1 投票 0

Gridview 分页/滚动

我有一个 Gridview ,其行数超出了屏幕上无需滚动即可显示的行数。 我将其添加到页面指令中: 维护ScrollPositionOnPostback =“true” 当我点击 e...

回答 2 投票 0

asp.net GridView 绑定与删除时分页冲突

我有一个带有 ObjectDataSource 的 Gridview : 我有一个带有 ObjectDataSource 的 Gridview : <asp:GridView ID="gvCompany" runat="server" SkinID="BasicGridView" DataSourceID="odsCompany" DataKeyNames="ID" OnRowCommand="gvCompany_RowCommand" OnRowDataBound="gvCompany_RowDataBound"> <Columns> <asp:TemplateField HeaderText="<%$ Resources:Titles, Select %>"> <ItemTemplate> <asp:CheckBox ID="chbSelect" TabIndex="5" runat="server" CssClass="contrast-checkbox" /> </ItemTemplate> <ItemStyle Width="50px" HorizontalAlign="Center" CssClass="center" /> <HeaderStyle CssClass="center" /> </asp:TemplateField> <asp:BoundField HeaderText="<%$ Resources:Titles,Code %>" DataField="Code" SortExpression="Code"> <ItemStyle Width="10%" /> </asp:BoundField> <asp:BoundField HeaderText="<%$ Resources:Titles,Name %>" DataField="Name" SortExpression="Name"> <ItemStyle Width="70%" /> </asp:BoundField> <asp:TemplateField HeaderText="<%$ Resources:Titles, Edit %>"> <ItemTemplate> <asp:LinkButton ID="lbtnEdit" TabIndex="7" runat="server" CommandName="EditCompany" CommandArgument='<%# ((GridViewRow)Container).RowIndex %>' CssClass="btn btn-contrast btn-xs edit-grid"> <i class="icon icon-edit"></i> </asp:LinkButton> </ItemTemplate> <ItemStyle Width="20px" HorizontalAlign="Center" CssClass="center" /> <HeaderStyle CssClass="center" /> </asp:TemplateField> <asp:TemplateField HeaderText="<%$ Resources:Titles, Delete %>"> <ItemTemplate> <a id="IbtnDelete" tabindex="8" class="btn btn-danger btn-xs edit-grid" onclick="return SetItemForDelete(this);"><i class="icon icon-trash-o"></i></a> </ItemTemplate> <ItemStyle Width="20px" HorizontalAlign="Center" CssClass="center" /> <HeaderStyle CssClass="center" /> </asp:TemplateField> </Columns> <EmptyDataTemplate> <%= Resources.Messages.NoCompanyIsForView%> </EmptyDataTemplate> </asp:GridView> <asp:ObjectDataSource ID="odsCompany" runat="server" EnablePaging="true" TypeName="DMS.Data.CompanyProvider" SelectMethod="Search" SortParameterName="orderby" SelectCountMethod="GetSearchCount" /> 当我转到 GridView 中的页面并删除该页面的所有行时,出现问题,在这种情况下,我绑定 Gridview 但显示 EmptyDataTemplate,而不是转到具有某些行的另一行.. 如何解决这个问题? 您将需要更改网格的 PageIndex 属性,因为它在重新绑定时不会自动更改。您可以在此处找到有关 PageIndex 属性的更多信息:http://msdn.microsoft.com/de-de/library/system.web.ui.webcontrols.gridview.pageindex(v=vs.110).aspx 在重新绑定之前,在您的方法/事件中重置页面索引,如下所示: if (gridView.PageIndex >= 1) gridView.PageIndex--; 如果您的页面索引为 0,那么您想显示 EmptyDataTable。 更新答案: 检查 Gridview 的 Rows.Count ,仅当当前页面索引中存在一行时才更改页面索引: if (gridView.PageIndex >= 1 && gridView.Rows.Count==1) gridView.PageIndex--;

回答 1 投票 0

尽管启用了分页,但无法使用分页

我正在尝试允许我的网格视图分页。我在我的网格视图中允许分页,并且还添加了页面大小。不幸的是,它不起作用。我研究过,发现人们不需要添加任何 c...

回答 2 投票 0

在更新面板中通过gridView分页时出现潜在危险的Request.Form错误

如果这是重复的问题,请原谅。我搜索并发现了很多关于此错误的帖子,但似乎没有一个对我有帮助(可能是由于我的无知)。 我得到了价值...

回答 1 投票 0

为什么我的Gridview点击第2页(分页)后会消失

我的数据库表中有 7 条记录,称为 EntryTable。我将页数限制设置为每页 5 条记录。因此第 1 页将有 5 条记录,第 2 页将有 2 条记录。但当我点击“搜索”后...

回答 1 投票 0

GridView 分页将焦点设置在页面底部而不是顶部

我有一个使用asp GridView 的网站。 当用户单击 gridview 底部的分页按钮时,页面会重新加载到底部。我需要将页面加载到顶部。 是...

回答 1 投票 0

垂直滚动时冻结 gridview 寻呼机

我有一个网格视图。 我必须实现分页以及使页面可以水平和垂直滚动。页面导航栏位于底部。 当垂直滚动页面时...

回答 1 投票 0

当我们使用浏览器后退按钮从另一个页面返回时,ASP.NET Gridview 分页不会保留

我的 ASP.NET 应用程序上有一个 gridview,我设置了 AutoGenerateColumns = false 并以编程方式填充它。这个gridview在updatepanel中排序和分页工作正常。我没有问题...

回答 1 投票 0

对部分类中的字段进行分页和排序实体框架

我有一个 GridView,它需要对来自 Customer 对象集合的数据进行分页和排序。 不幸的是我的客户信息是单独存储的...客户信息是存储的...

回答 2 投票 0

ASP.Net GridView 分页器未显示正确的页码

在 ASP.Net GridView 中,您是否遇到过这种情况? Web 表单有一个 GridView 和一个 DetailsView。用户寻呼到特定页面,例如第 3 页。寻呼机显示当前页面是第 3 页....

回答 1 投票 0

Gridview 中的分页不起作用第二页数据未显示数据?

我的网格视图 我的网格视图 <div style="margin-left: 280px"> <asp:GridView ID="exportGrdVw" runat="server" BackColor="White" AllowPaging="True" PageSize="3" OnPageIndexChanging="exportGrdVw_PageIndexChanging" onpageindexchanged="exportGrdVw_PageIndexChanged"> </asp:GridView> </div> 我的代码 SqlConnection con = new SqlConnection("server=acer-Pc\\Sql;database=MYDB;trusted_connection=yes"); //DataSet ds = new DataSet(); DataTable table = new DataTable(); protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SqlDataAdapter da = new SqlDataAdapter("select customername,contactno,address from employee ", con); da.Fill(table); BindEmployee(); } } public void BindEmployee() { exportGrdVw.DataSource = table; exportGrdVw.DataBind(); } protected void exportGrdVw_PageIndexChanging(object sender, GridViewPageEventArgs e) { exportGrdVw.PageIndex = e.NewPageIndex; BindEmployee(); } 问题是 gridview 正在显示,但当我单击第 2 页时,第 2 页数据未显示(空白)。请帮我解决这个问题。 看看代码是否正确 像下面这样使用 SqlConnection con = new SqlConnection("server=acer-Pc\\Sql;database=MYDB;trusted_connection=yes"); //DataSet ds = new DataSet(); DataTable table = new DataTable(); protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindEmployee(); } } public void BindEmployee() { SqlDataAdapter da = new SqlDataAdapter("select customername,contactno,address from employee ", con); da.Fill(table); exportGrdVw.DataSource = table; exportGrdVw.DataBind(); } protected void exportGrdVw_PageIndexChanging(object sender, GridViewPageEventArgs e) { exportGrdVw.PageIndex = e.NewPageIndex; BindEmployee(); } 您的数据表在每个页面加载时都会初始化,因此您需要获取数据表 每次将其绑定到网格之前。 在将页面绑定到网格之前设置页面索引 所以你的代码应该是这样的 public void BindEmployee(int newPageIndex = -1) { SqlDataAdapter da = new SqlDataAdapter("select customername,contactno,address from employee ", con); da.Fill(table); exportGrdVw.PageIndex = newPageIndex; exportGrdVw.DataSource = table; exportGrdVw.DataBind(); } 无需在 exportGrdVw_PageIndexChanging 上调用数据库。只需将 DataTable 表声明为 static 你可以试试这个: GridView1.PageIndex = e.NewPageIndex; SqlCommand cmd = new SqlCommand("Select * from Emp_Data ORDER BY [ID] DESC", con); SqlDataAdapter DA1 = new SqlDataAdapter(cmd); DA1.Fill(DT1); GridView1.DataSource = DT1; GridView1.DataBind();

回答 4 投票 0

GridView OnPageIndexChanging 事件不会触发

我的 GridView 和后面的代码似乎一切都很好,但事件没有触发。 这是我的网格: 我的 GridView 和后面的代码似乎一切都很好,但事件没有触发。 这是我的网格: <asp:UpdatePanel ID="ISOSearchUpdatePanel" runat="server"> <ContentTemplate> <div id="divIsoSelect" style="width:700px; height:60px; background-color:white"> <fieldset> <legend style="font-size: larger; font-weight: bold">Search ISO by</legend> <table> <tr> <td><asp:DropDownList ID="ddlISOSearch" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlISOSearch_SelectedIndexChanged"> <asp:ListItem Value="">Select...</asp:ListItem> <asp:ListItem Value="ISO Number" >ISO Number</asp:ListItem> <asp:ListItem Value="Name">Name</asp:ListItem> <asp:ListItem Value="Region" >Region</asp:ListItem> <asp:ListItem Value="Division">Division</asp:ListItem> </asp:DropDownList></td> <td >&nbsp;</td> <td> <asp:Panel ID="pnlSearchEntry" runat="server" Visible="false" style="width:500px; border:gainsboro; border-width: thick;"> <table> <tr> <td valign="middle" style="width:120px"><asp:Label ID="lblEntry" runat="server" Text=""></asp:Label></td> <td valign="top"><asp:TextBox ID="txtSearchValue" runat="server"> </asp:TextBox></td> <td valign="top">&nbsp;&nbsp;<asp:Button ID="btnFind" runat="server" Text="Select" OnClick="btnFind_Click"/></td> </tr> </table> </asp:Panel> </td> </tr> </table> </fieldset> </div> <asp:GridView ID="grvIsoSearchResults" runat="server" AutoGenerateColumns="false" PageSize="15" AllowPaging = "true" Visible="false" BorderColor="Red" GridLines="Both" OnRowCommand="grvIsoSearchResults_RowCommand" DataKeyNames="isonum" OnPageIndexChanged="grvIsoSearchResults_PageIndexChanged" OnPageIndexChanging="grvIsoSearchResults_PageIndexChanging" OnSorting="grvIsoSearchResults_Sorting" style="position:absolute; top: 120px;"> <PagerSettings firstpagetext="First" lastpagetext="Last" nextpagetext="Next" pagebuttoncount="100" /> <Columns> <asp:TemplateField HeaderText="ISONUM" SortExpression="isonum"> <ItemTemplate> <asp:Label ID="txtgvIsoNum" Text = '<%# Eval("ISONUM")%>' runat="server" Width="70px" style="text-align:center" /> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="OFFICE NAME" SortExpression="isoofficename"> <ItemTemplate> <asp:Label ID="txtgvIsoOfficeName" Text = '<%# Eval("ISOOFFICENAME")%>' runat="server" Width="200px" style="text-align:center" /> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="REGION" SortExpression="region"> <ItemTemplate> <asp:Label ID="txtgvRegion" Text = '<%# Eval("REGION")%>' runat="server" Width="50px" style="text-align:center" /> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="DIVISION" SortExpression="client_id"> <ItemTemplate> <asp:Label ID="txtgvDivision" Text = '<%# Eval("CLIENT_ID")%>' runat="server" Width="50px" style="text-align:center" /> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="EMAIL ADDRESS"> <ItemTemplate> <asp:TextBox ID="txtgvEmailAddress" Text = '<%# Eval("EMAIL")%>' runat="server" Width="200px" /> <asp:Button ID="btnEmailUpdate" Text = "Update" runat="server" CommandName="UpdateEmail" onClientClick="return ValidateEmail(this)" /> </ItemTemplate> </asp:TemplateField> </Columns> <pagerstyle backcolor="#005482" ForeColor="White" height="30px" verticalalign="Bottom" horizontalalign="Center"/> </asp:GridView> </ContentTemplate> </asp:UpdatePanel> 这是我的代码隐藏方法: private void SetViewState(DataSet myDataSet) { ViewState["Data"] = myDataSet; } private DataSet GetViewState() { return (DataSet)ViewState["Data"]; } private void LoadData(String selection, String userInput) { DataSet ds = new DataSet(); . . . ds = ISOProcessing.GetISOData(selection, userInput); grvIsoSearchResults.DataSource = ds; if (ds.Tables[0].Rows.Count > 0) { SetViewState(ds); grvIsoSearchResults.DataBind(); grvIsoSearchResults.Visible = true; } else { lblMsg.ForeColor = System.Drawing.Color.Red; this.lblMsg.Text = "No data for current selection"; } } protected void grvIsoSearchResults_PageIndexChanging(object sender, GridViewPageEventArgs e) { grvIsoSearchResults.PageIndex = e.NewPageIndex; grvIsoSearchResults.DataSource = GetViewState(); grvIsoSearchResults.DataBind(); } 一切似乎都已就位,但是当我在调试期间想要转到另一个页面时,在我的 grvIsoSearchResults_PageIndexChanging() 方法内部甚至没有命中断点。我不确定为什么会发生这种情况。 需要你的帮助。 谢谢你 尝试为其添加触发器: </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="grvIsoSearchResults" EventName="PageIndexChanging" /> </Triggers> </asp:UpdatePanel> Gridview 的 AutoPostback 属性未启用,请像这样将其设置为 true。 <asp:GridView ID="grvIsoSearchResults" AutoPostback="True" runat="server" AutoGenerateColumns="false" PageSize="15" AllowPaging = "true" Visible="false" BorderColor="Red" GridLines="Both" OnRowCommand="grvIsoSearchResults_RowCommand" DataKeyNames="isonum" OnPageIndexChanged="grvIsoSearchResults_PageIndexChanged" OnPageIndexChanging="grvIsoSearchResults_PageIndexChanging" OnSorting="grvIsoSearchResults_Sorting" style="position:absolute; top: 120px;"> <PagerSettings firstpagetext="First" lastpagetext="Last" nextpagetext="Next" pagebuttoncount="100" /> <Columns> <asp:TemplateField HeaderText="ISONUM" SortExpression="isonum"> <ItemTemplate> <asp:Label ID="txtgvIsoNum" Text = '<%# Eval("ISONUM")%>' runat="server" Width="70px" style="text-align:center" /> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="OFFICE NAME" SortExpression="isoofficename"> <ItemTemplate> <asp:Label ID="txtgvIsoOfficeName" Text = '<%# Eval("ISOOFFICENAME")%>' runat="server" Width="200px" style="text-align:center" /> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="REGION" SortExpression="region"> <ItemTemplate> <asp:Label ID="txtgvRegion" Text = '<%# Eval("REGION")%>' runat="server" Width="50px" style="text-align:center" /> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="DIVISION" SortExpression="client_id"> <ItemTemplate> <asp:Label ID="txtgvDivision" Text = '<%# Eval("CLIENT_ID")%>' runat="server" Width="50px" style="text-align:center" /> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="EMAIL ADDRESS"> <ItemTemplate> <asp:TextBox ID="txtgvEmailAddress" Text = '<%# Eval("EMAIL")%>' runat="server" Width="200px" /> <asp:Button ID="btnEmailUpdate" Text = "Update" runat="server" CommandName="UpdateEmail" onClientClick="return ValidateEmail(this)" /> </ItemTemplate> </asp:TemplateField> </Columns> <pagerstyle backcolor="#005482" ForeColor="White" height="30px" verticalalign="Bottom" horizontalalign="Center"/> </asp:GridView>

回答 2 投票 0

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.