Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Hi,
 
I want scroll paging on my web page . I'm writing code Asp.net and C# 4.0 for this project. I don't want stored procedure , i want only ado.net connections.
 

 
<asp:repeater ID=NewsRepeater runat="server">
<ItemTemplate>
            <div id="content-bottom">
                <div class="content-bottom-inner">
                    <ul>
                        <li>
                            <h4>
                                <%#DataBinder.Eval(Container.DataItem,"NewsTitle") %></h4>
                        </li>
                        <li>
                            <%#DataBinder.Eval(Container.DataItem,"NewsImg") %>
                        </li>
                        <li>
                            <%#DataBinder.Eval(Container.DataItem,"NewsText") %>
                        </li>
                        <li>
                            <%#DataBinder.Eval(Container.DataItem,"NewsLink") %>
                        </li>
                    </ul>
                </div>
            </div>
        </ItemTemplate>
 
</asp:repeater>
<script type="text/javascript">
    $(window).scroll(function () {
        if ($(window).scrollTop() == $(document).height() - $(window).height())
        {
            
        
                        $.ajax({
                    type: "POST",
                    url: "Default3.aspx/ItemsGet",
                    data: "{}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: AjaxSucceeded,
                    error: AjaxFailed
                });
             
            function AjaxSucceeded() {
                alert("result.d");
            }
            function AjaxFailed() {
                alert("Failed");
            }
        }
    });</script>
 
public int CurrentPage
    {
        get
        {
            // look for current page in ViewState
            object o = this.ViewState["_CurrentPage"];
            if (o == null)
                return 0;       // default to showing the first page
            else
                return (int)o;
        }
 
        set
        {
            this.ViewState["_CurrentPage"] = value;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
 
        ItemsGet();
    }
    [WebMethod]
    public void ItemsGet()
    {
 
        SqlConnection myConnection = new SqlConnection("Data Source=localhost\\sqlexpress;Initial Catalog=db1;Integrated Security=True");
        SqlDataAdapter myCommand = new SqlDataAdapter("SELECT [NewsTitle],[NewsImg] ,[NewsText],[NewsLink] FROM NewsTable ORDER BY id desc", myConnection);
      
        DataSet ds = new DataSet();
       
        myCommand.Fill(ds);
        PagedDataSource objPds = new PagedDataSource();
        objPds.DataSource = ds.Tables[0].DefaultView;
        objPds.AllowPaging = true;
        objPds.PageSize = 3;
 
        objPds.CurrentPageIndex = CurrentPage;
 
       
 
        NewsRepeater.DataSource = objPds;
        NewsRepeater.DataBind();
    }
 
I'm tryed this code but not working. I want write similar this code , because i use 'where' in sql sentences, so a lot where .
 
For Example;
 
If checkbox1 and checkbox2 selected than etc.
 
[WebMethod]
    public void ItemsGet()
    {
 
        SqlConnection myConnection = new SqlConnection("Data Source=localhost\\sqlexpress;Initial Catalog=db1;Integrated Security=True");
        SqlDataAdapter myCommand = new SqlDataAdapter("SELECT [NewsTitle],[NewsImg] ,[NewsText],[NewsLink] FROM NewsTable where check = @checked and check2 =@checked2 ORDER BY id desc", myConnection);
      
        DataSet ds = new DataSet();
       
        myCommand.Fill(ds);
        PagedDataSource objPds = new PagedDataSource();
        objPds.DataSource = ds.Tables[0].DefaultView;
        objPds.AllowPaging = true;
        objPds.PageSize = 3;
 
        objPds.CurrentPageIndex = CurrentPage;
 
       
 
        NewsRepeater.DataSource = objPds;
        NewsRepeater.DataBind();
    }
 
How is make this ? Have you got a example project ? Thanks
Posted 14-Jan-13 9:14am

1 solution

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

  Print Answers RSS
0 CPallini 355
1 BillWoodruff 334
2 George Jonsson 279
3 Sergey Alexandrovich Kryukov 243
4 Gihan Liyanage 225
0 OriginalGriff 5,050
1 CPallini 4,225
2 Sergey Alexandrovich Kryukov 3,639
3 George Jonsson 2,911
4 Gihan Liyanage 2,386


Advertise | Privacy | Mobile
Web01 | 2.8.140916.1 | Last Updated 14 Jan 2013
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