Gridview是用于显示和操作来自各种数据源的数据的控件。
我有一个网格视图,设置为进行分页,但它无法正常工作。 只有第一页的控件是可见的 - 其他页面有呈现的框,但其中没有控件。 有人吗
我有一个带有 GridView 的 asp.net 网页 我有一个带有 GridView 的 asp.net 网页 <asp:GridView ID="grid_view" runat="server" AllowPaging="True" AutoGenerateColumns="False" BackColor="White" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CellPadding="3" ForeColor="Black" GridLines="Vertical"> <FooterStyle BackColor="#CCCCCC" /> <Columns> <asp:BoundField DataField="adc" HeaderText="Posa No." /> <asp:BoundField DataField="cde" HeaderText="Unit" /> <asp:BoundField DataField="efg" HeaderText="User" /> <asp:BoundField DataField="hj" HeaderText="Posa Date" /> </Columns> <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" /> <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" /> <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" /> <AlternatingRowStyle BackColor="#CCCCCC" /> </asp:GridView> 我的代码是 protected void Page_Load(object sender, EventArgs e) { con = new SqlConnection(ConfigurationManager.AppSettings["Connection"]); gridfil(); } public void gridfil() { con.Open(); cmd = new SqlCommand("select a,b,c from xyz where approved='sss'", con); SqlDataAdapter da = new SqlDataAdapter(cmd); SqlCommandBuilder cb = new SqlCommandBuilder(da); DataSet ds = new DataSet(); da.Fill(ds); grid_view.DataSource = ds; grid_view.DataBind(); //rd.Close(); da.Dispose(); cmd.Dispose(); con.Close(); } protected void grid_view_PageIndexChanging(object sender, GridViewPageEventArgs e) { grid_view.PageIndex = e.NewPageIndex; gridfil(); } 我的问题是网格视图已显示,但页面索引不起作用...... 有人有什么建议吗? 将页面加载代码放在 !IsPostBack() 下 protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { con = new SqlConnection(ConfigurationManager.AppSettings["Connection"]); gridfil(); } } 原因: 每当您单击页码并想要查看另一个页面时,页面将被回发,并且您的 page load event 在 grid_view_PageIndexChanging 之前触发,它将重新绑定 gridview,您的事件将丢失,并且不会触发 PageIndexChanging活动。 再改一下看看评论 protected void grid_view_PageIndexChanging(object sender, GridViewPageEventArgs e) { gridfil(); // First bind the gridview grid_view.PageIndex = e.NewPageIndex; // then change the page Index }
ASP.Net GridView UpdatePanel 分页在第二次单击时出现错误
我正在尝试在 UpdatePanel 内实现带有分页的 GridView。 当我第一次点击时,一切都很好。 分页开始并快速加载下一组数据。 然而,当...
我的应用程序有一个小进步,在 fx4.0 上使用 ASP.Net 和 C# 进行开发。要求是我的客户需要动态分页大小。他想将所有 gridview 的页面大小设置为大约 10-15 ,如
分页在 AJAX updatepanel 内的 asp.net gridview 中不起作用
我有一个最初绑定到sqldatasource控件的asp.net gridview,但是当用户按下外部按钮时,它获取的是数据表的内容而不是SQLdatasource
我在 UpdatePanel 中的 GridView 中应用了分页。当我前进到下一个结果集时,我的页面上会发生完整的回发。我需要在 web.config 文件或我的代码中进行一些修改吗...
我在 UpdatePanel (ASP.Net 2.0) 中有一个 GridView 。 我有网格视图的 PageIndexChanging 方法的代码: protected void grdProductSearch_PageIndexChanging(对象发送者,
我正在从sql数据库检索数据。我想分割记录并将其绑定在三个不同的网格中。在应用分页之前一切工作正常。我得到数据源没有
好吧,请耐心听我说,因为我有时会有点像木鸭...... 我在 asp.net 中有一个 gridview,它将拉回数千条记录。除了性能之外,这一切都很好......
我有一个嵌套在网格视图中的列表视图。 我正在尝试在列表视图上进行分页。 我以为它会显示分页控件,然后正常地翻阅它们。 它确实...
我的 linqdatasource 有问题。我的页面中有 gridview ,并将其数据源设置为 linqdatasource ,还设置了 AllowPaging="True" 、AllowSorting="True" 。 我的 linqdatasource 有问题。我的页面中有 gridview ,并将其数据源设置为 linqdatasource ,还设置了 AllowPaging="True" 、AllowSorting="True" 。 <asp:GridView ID="cityGrid" runat="server" AutoGenerateColumns="False" DataKeyNames="CityId" AllowPaging="True" AllowSorting="True" DataSourceID="LinqCityData"> 现在在linqdatasource中我想从两个表(带有FK的关系表)中检索数据,这一步没有问题。 我可以像这样使用 linqdatasource 的 Select 属性从其他表中进行选择 <asp:LinqDataSource ID="LinqCityData" runat="server" ContextTypeName="ContactSysDataContext" TableName="Office_ContactSys_Cities" Select="new (CityId, CityName , Office_ContactSys_Province.ProvinceName)"> </asp:LinqDataSource> 或者我在 linqdatasource 中使用 Selection 事件 protected void LinqCityData_Selecting(object sender, LinqDataSourceSelectEventArgs e) { ContactSysDataContext db = new ContactSysDataContext(); var CityResult= from p in db.Office_ContactSys_Cities join o in db.Office_ContactSys_Provinces on p.ProvinceId equals o.ProvinceId select new { o.ProvinceName, p.CityId, p.CityName }; e.Result = CityResult; } 但在此步骤之后,我无法在 linqdatasource 中使用自动删除,而是收到此错误: LinqDataSource 'LinqCityData' 没有 支持 Select 属性时 删除、插入或更新操作 已启用 这是我的问题:如何使用linqdatasource(启用删除或更新的linqdatasource)在gridview(当然对于关系表)中实现分页? 如果从 linqdatasource 中删除 select 语句,您将不会再收到该错误。 然后就可以使用更新、删除和插入。 哦,您还必须在数据源中启用删除、插入和更新。 这是一个例子: <asp:LinqDataSource ID="LinqDataSource1" runat="server" ContextTypeName="Custom.Data.DataAccessDataContext" TableName="CustomerSegmentMappings" EnableDelete="True" EnableInsert="True" EnableUpdate="True"> </asp:LinqDataSource>
我正在使用 PageIndexChanging 事件来处理 C# 中的 GridView 分页。但不知道如何在那里使用 PageSize/PageNumber/PageCount 。换句话说,我的代码被迫始终返回所有数据。 ...
我有一个使用分页的datagridview,它工作得很好,我有一个下拉菜单,允许用户更改“PageSize”属性 - 10、15、25、50、100、1000 等。 当我选择一个 v...
使用 Linq 查询作为数据源的 ASP.NET GridView 分页
当我使用 linq 查询在运行时设置数据源时,我正在寻找一种使用 GridView 进行分页的方法。 这是我的代码: ETDataContext etdc = new ETDataContext(); var accts = 来自 etdc 中的 a。
是否有某种方法可以强制显示gridview的分页器,即使屏幕上只有一页数据? 我正在使用自定义分页器构建基于 gridview 的控件(带有页面大小的下拉菜单)...
我很好奇asp.net中的分页是如何工作的? 如果我的查询返回500条记录,而我的gridview分页限制为每页25条记录,当gridview加载时,记录集是否返回25条记录...
我有一个页面大小=4的gridview,我需要的是如何为网格视图中的所有行进行for循环,而不仅仅是在当前页面中? 非常感谢
网格视图 网格视图 <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" PagerSettings-Position="TopAndBottom" PagerSettings-Mode="Numeric" PageSize="40" CellPadding="4" DataSourceID="dsEquipmentGridView" ForeColor="#333333" GridLines="Horizontal" Style="font-size: x-small" AutoGenerateColumns="False" DataKeyNames="IREF" OnRowEditing="GridView1_RowEditing" OnRowUpdated="GridView1_RowUpdated" OnSorted="GridView1_Sorted" OnSorting="GridView1_Sorting" OnPageIndexChanged="GridView1_PageIndexChanged1" OnPageIndexChanging="GridView1_PageIndexChanging" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" OnSelectedIndexChanging="GridView1_SelectedIndexChanging" OnRowCommand="GridView1_RowCommand" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" OnRowCancelingEdit="GridView1_RowCancelingEdit" onload="GridView1_Load" ondatabound="GridView1_DataBound"> <PagerSettings Position="TopAndBottom" /> <RowStyle BackColor="#F7F6F3" ForeColor="#333333" /> <Columns> <asp:CommandField ShowDeleteButton="False" ShowSelectButton="true" EditText="QuickEdit" HeaderText="Manage" SelectText="Manage" /> 对于加载的第一页,如果我单击命令字段,它会显示正确的 DataKey 值。 但是,如果我切换到下一页结果,在选择记录时,相应的值不正确。似乎保留了上一页的信息。我该如何克服这个问题? 编辑: 在GridView1_SelectedIndexChanged方法中,我使用了以下内容: // Determine the index of the selected row. int index = GridView1.SelectedIndex; // Display the primary key value of the selected row. HttpContext.Current.Response.Write("The primary key value of the selected row is " + GridView1.DataKeys[index].Value.ToString() + ".<br>"); GridViewRow row = GridView1.Rows[index]; int rowindex = row.RowIndex; HttpContext.Current.Response.Write("rowindex-> " + rowindex.ToString() + "<br>"); int ID = (int)GridView1.DataKeys[row.DataItemIndex - (GridView1.PageIndex * GridView1.PageSize)].Value; HttpContext.Current.Response.Write("row.DataItemIndex" + ID.ToString()+"<br>"); int Userid = Convert.ToInt32(GridView1.DataKeys[index].Value); HttpContext.Current.Response.Write("Userid" + Userid.ToString() + "<br>"); 分页后无法获取正确的值。 使用分页时,我们可以获得准确的行索引(在gridview中从0到totalrows计数) 并且在获取datakey时,我们需要传递当前页面的行索引。 使用下面的行获取当前页面索引并获取数据密钥: // Get the correct row index since there is paging int idx = gridViewRow.DataItemIndex - TestGridView.PageIndex * TestGridView.PageSize; 我可能会迟到。 但对于其他人,我回复这个。 “使用 DataKey 数组之前再次重新绑定 gridview” 它对我有用。 希望它也适用于其他人。 不久前已修复。正在使用第三方 GridView 帮助程序类。这破坏了 GridView 的正常功能。
从启用分页的 GridView 控件中检索所有 GridViewRow 对象
我当前的 aspx 页面上有一个启用分页的 GridView 控件,我需要循环遍历整个行集合/计数来处理选定的记录。 使用我当前的代码,它只会
使用 VB.Net 的标准 .net 2.0 Gridview 的分页问题
我正在使用标准的 .net 2.0 Gridview,它使用 XMLDatasource 来填充网格。 XMLDatasource 的 Data 属性是动态设置的,它允许 gridview 根据输入进行更改...