Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
I am developing a website in asp.net.I have taken a 'Datalist' control for uploading the images.But when the no. of images increases then the problem create so I want to give the Paging . So how to give the Paging.
 
Here is the whole code where i want to apply the Datalist Paging:------So Now You can understand that what I Really want?
So give me the proper solution.
 
The aspx code of the Datalist for uploading the images:----
 
<asp:DataList ID="DataList1" runat="server" RepeatDirection="Horizontal"
    RepeatColumns="4" BackColor="White" BorderColor="#CC9966" BorderStyle="Solid"
     BorderWidth="1px" CellPadding="4" GridLines="Both"
        onitemcommand="DataList1_ItemCommand" Font-Size="Small" >
        <FooterStyle BackColor="#FFFFCC" ForeColor="#330099" />
        <ItemStyle BackColor="White" ForeColor="#330099" />
        <SelectedItemStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" />
        <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="#FFFFCC" />
        <ItemTemplate>
          <asp:ImageButton ID="ImageButton1" runat="server" Height="120px" Width="180px" ImageUrl=' <%#Eval("url")%>' CommandName="select" CommandArgument='<%#Eval("url") %>' />
            <br />
             Head Line : <%#Eval("headline") %>
             <br />
             Publication : <%#Eval("publication") %>
             <br />
             Edition : <%#Eval("edition") %>
             <br />
             Date : <%#Eval("date") %>
            </ItemTemplate>
        </asp:DataList>
 

 

 

The code behind(aspx.cs)code is given below:-----
 
 protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            imagebind2();
            
        }
    }
 
    private void imagebind2()
    {
        try
        {
            string selectSQL = "SELECT headline,publication,edition,date,url FROM competion";
            SqlConnection cnn = new SqlConnection(connectionString);
            SqlDataAdapter adp = new SqlDataAdapter(selectSQL, cnn);
            DataSet ds = new DataSet();
            adp.Fill(ds);
            DataList1.DataSource = ds;
            DataList1.DataBind();
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }
    }
 
    protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
    {
        try
        {
            if (e.CommandName == "select")
            {
                SqlConnection cnn = new SqlConnection(connectionString);
                string selectSQL = "SELECT publication,edition,date,url FROM competion where url='" + e.CommandArgument.ToString() + "'";
                SqlDataAdapter adp = new SqlDataAdapter(selectSQL, cnn);
                DataTable dt = new DataTable();
                adp.Fill(dt);
                DataRow dr = dt.Rows[0];
 
                //Image1.ImageUrl =dr["url"].ToString();
                //Label1.Text=dr["publication"].ToString();
                //Label2.Text=dr["edition"].ToString();
                //Label3.Text = dr["date"].ToString();
 
                Session["url1"] = dr["url"].ToString();
                //Session["publication"]=dr["publication"].ToString();
                //Session["edition"] = dr["edition"].ToString();
                //Session["date"] = dr["date"].ToString();
                Response.Redirect("~/ImageDiscription.aspx");
 
                //on page load
                //Image1.ImageUrl=Session["url1"].ToString();
 
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }
    }
Posted 23-Sep-11 21:37pm
Edited 25-Sep-11 20:31pm
v4
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

this definitely helps:
http://forums.asp.net/t/1108198.aspx[^]
  Permalink  
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

//fill datalist with 10 record per page.

 PagedDataSource pds = new PagedDataSource();
pds.DataSource = mydatatable.DefaultView;
        pds.AllowPaging = true;
        pds.PageSize = 10;
        pds.CurrentPageIndex = currentpage;
        count = pds.PageCount;       
        DataList1.DataSource = pds;
        DataList1.DataBind();
 

//next button click_event
if (Session["cp"] != null)
        {
            currentpage = (int)(Session["cp"]);       
        }
        else
        {
            currentpage = 0;
        }         
            currentpage += 1;
            Session.Add("cp", currentpage);
            filllist();           
        }
        
//previous button_click event
if (Session["cp"] != null)
        {
            currentpage = (int)(Session["cp"]);       
        }
        else
        {
            currentpage = 0;
        }         
            currentpage -= 1;
            Session.Add("cp", currentpage);
            filllist();           
        }
 
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

  Permalink  
Comments
deepureddy18 at 1-Jun-12 7:54am
   
check it
http://www.netomatix.com/development/datalistpaging.aspx[^]
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

Go through below link
 
http://forums.asp.net/t/1108198.aspx[^]
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 751
1 George Jonsson 330
2 Garth J Lancaster 290
3 Sergey Alexandrovich Kryukov 274
4 BillWoodruff 252
0 Sergey Alexandrovich Kryukov 10,879
1 OriginalGriff 5,555
2 Maciej Los 5,534
3 CPallini 3,819
4 BillWoodruff 3,594


Advertise | Privacy | Mobile
Web02 | 2.8.141030.1 | Last Updated 30 Aug 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100