Grid View Paging
Grid View paging-
Grid view paging is used when we have to read the data in bulk then we divide the complete data records into pages consists 10 records in one page.
SqlDataAdapter - It is used for Grid View Paging Data Adapter reads data in group of 10 records unlike DataReader which reads the data line by line.
DataSet - DataSet Object is created, it accepts the data in bulk.
Fill() - Fill() is used.
CODE-
protected void display()
{
//Connection Code
string s = ConfigurationManager.AppSettings["db"];
cn = new SqlConnection(s);
cn.Open();
//DataSet Object
DataSet ds = new DataSet();
string s = "select * from Videodb";
//SqlDataAdapter object
SqlDataReader adp = new SqlDataAdapter();
adp.Fill(ds);
GridView1.DataSoruce = ds;
GridView1.DataBind();
}
Source code-
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
Height="589px" Width="483px" OnPageIndexChanging="click" AllowPaging="true">
<asp:GridView>
Code Window-
protected void click(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
display();
}
Comments
Post a Comment