hmm the code for datalist paging is as follows
public void binddata()
{
//uid = “dharma.sonu@gmail.com1″;
uid = Session["user"].ToString() + “1″;
qid = Request.QueryString["qid"].ToString();
string query = “select * from albumpics where userid=’” + uid + “‘ and albumname=’” + qid + “‘”;
SqlDataAdapter da = new SqlDataAdapter(query, con);
con.Close();
con.Open();
DataSet ds = new DataSet();
int startRecord = (int.Parse(CurrentPage.Value) – 1) *
int.Parse(PageSize.Value);
da.Fill(ds, startRecord, int.Parse(PageSize.Value), “albumpics”);
if (ds.Tables[0].Rows.Count > 0)
{
DataList1.DataSource = ds;
DataList1.DataBind();
}
//Second Part
//Create a new Command to select the total number of records
SqlCommand myCmd = new SqlCommand(“SELECT Count(*) from albumpics where userid=’” + uid + “‘ and albumname=’” + qid + “‘”, con);
con.Close();
con.Open();
//retrieve the value
TotalSize.Value = myCmd.ExecuteScalar().ToString();
BuildPagers();
}
public void Page_DataList(object sender, EventArgs e)
{
//Check for Button clicked
if (((LinkButton)sender).ID == “Prev”)
{
//Check if we are on any page greater than 0
if ((int.Parse(CurrentPage.Value) – 1) >= 0)
{
//Decrease the CurrentPage Value
CurrentPage.Value = (int.Parse(CurrentPage.Value) – 1).ToString();
}
}
else if (((LinkButton)sender).ID == “Next”)
{
//Check if we can display the next page.
if ((int.Parse(CurrentPage.Value) * int.Parse(PageSize.Value))
< int.Parse(TotalSize.Value))
{
//Increment the CurrentPage value
CurrentPage.Value = (int.Parse(CurrentPage.Value) + 1).ToString();
}
}
//Rebuild the Grid
binddata();
}
public void BuildPagers()
{
//Check if its possible to have the previous page
if ((int.Parse(CurrentPage.Value) – 1) <= 0)
{
Prev.Enabled = false;
}
else
{
Prev.Enabled = true;
}
//Check if its possible to have the next page
if ((int.Parse(CurrentPage.Value) * int.Parse(PageSize.Value))
>= int.Parse(TotalSize.Value))
{
Next.Enabled = false;
}
else
{
Next.Enabled = true;
}
}
<asp:DataList ID=”DataList1″ runat=”server” RepeatColumns=”3″>
<ItemTemplate>
<table id=”Table3″ cellSpacing=”1″ cellPadding=”2″ border=”0″>
<tr>
<td >
<asp:ImageButton ID=”ImageButton1″ runat=”server” ImageUrl=’<%# getpath(DataBinder.Eval(Container.DataItem,”imgid”).ToString())%>’ OnClick=”ImageButton1_Click” />
</td>
<td>
<table >
<asp:Panel ID=”Panel1″ runat=”server” Visible=”false” >
<tr>
<td>
<asp:Label ID=”Label2″ runat=”server” Text=”Caption :”></asp:Label><asp:TextBox ID=”txtcap”
runat=”server” TextMode=”MultiLine” Text=’<%# DataBinder.Eval(Container.DataItem,”Description”).ToString()%>’></asp:TextBox></td>
</tr>
<tr>
<td align=”left”>
<asp:RadioButton ID=”RBcover” runat=”server” TextAlign =”right” Text =”Album Cover”/></td>
</tr>
</asp:Panel>
<tr>
<td align=”left” >
<table >
<tr>
<td align=”center” >
<asp:LinkButton ID=”LinkButton1″ runat=”server” OnClick =”LinkButton1_Click2″>Edit</asp:LinkButton></td> <td>
<asp:LinkButton ID=”LinkButton2″ runat=”server” OnClick =”LinkButton2_Click1″>Delete</asp:LinkButton></td>
</tr>
</table>
</td>
</tr>
</table>
</td></tr>
<tr>
<td>
<asp:Label ID=”Label1″ runat=”server” Text=’<%# DataBinder.Eval(Container.DataItem,”Description”).ToString()%>’ ></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID=”lblimgid” runat=”server” Text=’<%# DataBinder.Eval(Container.DataItem,”imgid”).ToString()%>’ Visible =”false” ></asp:Label>
</td>
</tr>
</table>
</ItemTemplate></asp:DataList>