Hi, I am using the paging skills for my page.
I'm doing manual databinding (that is, setting the DataSource property, and then calling DataBind()) instead of automatic databinding. So I manually handle events for paging. But the page is invisible.
Thanks for your help.
I'm doing manual databinding (that is, setting the DataSource property, and then calling DataBind()) instead of automatic databinding. So I manually handle events for paging. But the page is invisible.
Thanks for your help.
Code:
protected void GridView_PageIndexChanging(object sender, GridViewPageEventArgs e) { DataSet myDataSet = new DataSet(); GenerateDataSet(myDataSet); // databind the page GridView1.DataSource = myDataSet.Tables["Weather"]; GridView1.PageIndex = e.NewPageIndex; GridView1.DataBind(); } void GenerateDataSet(DataSet dset) { AddTable(dset); } void AddTable(DataSet dset) { // create the table DataTable WeatherTable = new DataTable("Weather"); DataColumn WeatherID = WeatherTable.Columns.Add("State", typeof(string)); WeatherTable.Columns.Add("Division", typeof(String)); WeatherTable.Columns.Add("Temp", typeof(string));
Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="First.aspx.cs" Inherits="FirstPage.GetStrings" %> <% @Import Namespace="My.Name.Space" %> <% @Import Namespace="My.Name.Space1" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.SqlClient" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <asp:GridView ID="GridView1" runat="server" AllowPaging="True"> </asp:GridView> </div> </form> </body> </html>
Comment