==============================================
HTML of Datalist
==============================================
<asp:datalist id="dsList" runat="server" width=100%>
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem, "ID").ToString()%>
<%#DataBinder.Eval(Container.DataItem, "Name").ToString()%>
</ItemTemplate>
</asp:datalist>
<table width="100%" border="0" align="Center">
<tr>
<td><asp:LinkButton id="lnkPrevious" runat="server">
</asp:LinkButton>
</td>
<td><asp:LinkButton id="lnkNext" runat="server">>
</asp:LinkButton>
</td>
</tr>
</table>===============================================
Server Side Coding : VB.NET
===============================================
Dim Start As Integer
Dim dbCon As SqlConnection
Dim Adpt As SqlDataAdapter
Dim dtUser As DataSet
Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
ViewState("Start") = 0
BindData()
End If
End Sub
Sub BindData()
dbCon = New SqlConnection("server=localhost;uid=sa;
pwd=;database=user")
Adpt = New SqlDataAdapter("Select * from user ", dbCon)
dtUser = New DataSet
Start = ViewState("Start")
ViewState("Size") = 14
Adpt.Fill(dtUser, Start, ViewState("Size"), "user")
dsList.DataSource = dtUser
dsList.DataBind()
End Sub
Private Sub lnkPrevious_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles lnkPrevious.Click
Start = ViewState("Start")- ViewState("Size")
ViewState("Start") = Start
If Start <= 0 Then ViewState("Start") = 0 End If BindData() End Sub Private Sub lnkNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lnkNext.Click Dim count As Integer = dsList.Items.Count Start = ViewState("Start") + ViewState("Size") ViewState("Start") = Start If count <>
=====================================================
Server Side Coding: c#
=====================================================
int Start ;
SqlConnection dbCon ;
SqlDataAdapter Adpt ;
DataSet dtUser ;
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack )
{
ViewState["Start"] = 0;
BindData();
}
}
void BindData()
{
dbCon = new SqlConnection("server=localhost;uid=sa;
pwd=;database=user");
Adpt = new SqlDataAdapter("Select * from user", dbCon);
dtUser = new DataSet();
Start = (int)ViewState["Start"];
ViewState["Size"] = 14;
Adpt.Fill(dtUser, Start,(int) ViewState["Size"], "user");
dsList.DataSource = dtUser;
dsList.DataBind();
}
private void lnkPrevious_Click(object sender, System.EventArgs e)
{
Start = (int) ViewState["Start"] -(int) ViewState["Size"];
ViewState["Start"] = Start;
if (Start <= 0 ) { ViewState["Start"] = 0; } BindData(); } private void lnkNext_Click(object sender, System.EventArgs e) { int count = dsList.Items.Count; Start = (int) ViewState["Start"]+(int) ViewState["Size"]; ViewState["Start"] = Start; if ( count < (int)ViewState["Size"] ) { ViewState["Start"] = (int)ViewState["Start"] - (int)ViewState["Size"]; } BindData(); }
HTML of Datalist
==============================================
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem, "ID").ToString()%>
<%#DataBinder.Eval(Container.DataItem, "Name").ToString()%>
</ItemTemplate>
</asp:datalist>
<table width="100%" border="0" align="Center">
<tr>
<td><asp:LinkButton id="lnkPrevious" runat="server">
</asp:LinkButton>
</td>
<td><asp:LinkButton id="lnkNext" runat="server">>
</asp:LinkButton>
</td>
</tr>
</table>===============================================
Server Side Coding : VB.NET
===============================================
Dim Start As Integer
Dim dbCon As SqlConnection
Dim Adpt As SqlDataAdapter
Dim dtUser As DataSet
Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
ViewState("Start") = 0
BindData()
End If
End Sub
Sub BindData()
dbCon = New SqlConnection("server=localhost;uid=sa;
pwd=;database=user")
Adpt = New SqlDataAdapter("Select * from user ", dbCon)
dtUser = New DataSet
Start = ViewState("Start")
ViewState("Size") = 14
Adpt.Fill(dtUser, Start, ViewState("Size"), "user")
dsList.DataSource = dtUser
dsList.DataBind()
End Sub
Private Sub lnkPrevious_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles lnkPrevious.Click
Start = ViewState("Start")- ViewState("Size")
ViewState("Start") = Start
If Start <= 0 Then ViewState("Start") = 0 End If BindData() End Sub Private Sub lnkNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lnkNext.Click Dim count As Integer = dsList.Items.Count Start = ViewState("Start") + ViewState("Size") ViewState("Start") = Start If count <>
=====================================================
Server Side Coding: c#
=====================================================
int Start ;
SqlConnection dbCon ;
SqlDataAdapter Adpt ;
DataSet dtUser ;
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack )
{
ViewState["Start"] = 0;
BindData();
}
}
void BindData()
{
dbCon = new SqlConnection("server=localhost;uid=sa;
pwd=;database=user");
Adpt = new SqlDataAdapter("Select * from user", dbCon);
dtUser = new DataSet();
Start = (int)ViewState["Start"];
ViewState["Size"] = 14;
Adpt.Fill(dtUser, Start,(int) ViewState["Size"], "user");
dsList.DataSource = dtUser;
dsList.DataBind();
}
private void lnkPrevious_Click(object sender, System.EventArgs e)
{
Start = (int) ViewState["Start"] -(int) ViewState["Size"];
ViewState["Start"] = Start;
if (Start <= 0 ) { ViewState["Start"] = 0; } BindData(); } private void lnkNext_Click(object sender, System.EventArgs e) { int count = dsList.Items.Count; Start = (int) ViewState["Start"]+(int) ViewState["Size"]; ViewState["Start"] = Start; if ( count < (int)ViewState["Size"] ) { ViewState["Start"] = (int)ViewState["Start"] - (int)ViewState["Size"]; } BindData(); }
Coding is simple and good...
ReplyDeleteBut numeric paging like ( 1,2,3 etc) required in many times.
By Sumeet Naik
Thanx a lot...i was very tensed because of this paging..
ReplyDelete