In aspx page:
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AllowPaging="true" PagerSettings-Mode="Numeric" PagerSettings-Position="TopAndBottom" PageSize="10" OnPageIndexChanging="GridView1_PageIndexChanging" >
</asp:GridView>
</div>
</form>
In code behind:
protected void Page_Load(object sender, EventArgs e)
{
adddata();
}
//Binding gridview
public void adddata()
{
conn.Open();
string strSQL = "Select * from LOGINDETAILS";
OleDbCommand cmd = new OleDbCommand(strSQL, conn);
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
conn.Close();
}
//paging index
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
adddata();
}
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AllowPaging="true" PagerSettings-Mode="Numeric" PagerSettings-Position="TopAndBottom" PageSize="10" OnPageIndexChanging="GridView1_PageIndexChanging" >
</asp:GridView>
</div>
</form>
In code behind:
protected void Page_Load(object sender, EventArgs e)
{
adddata();
}
//Binding gridview
public void adddata()
{
conn.Open();
string strSQL = "Select * from LOGINDETAILS";
OleDbCommand cmd = new OleDbCommand(strSQL, conn);
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
conn.Close();
}
//paging index
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
adddata();
}
output:
No comments:
Post a Comment