Paging is not working in radgrid

6 posts, 3 answers
  1. avinash
    avinash  avatar
    9 posts
    Member since:
    Apr 2014

    Posted 19 May 2014 Link to this post

    hi,

    I am trying to implement paging in rad grid , but when i click from 1st page to 2nd radgrid is not dispalying any data.

    what i  am doing iin aspx page below:-

      <form id="form1" runat="server">
        <div>
        <telerik:RadGrid ID="radgrdidemo"  OnNeedDataSource="RadGrid1_NeedDataSource"  AutoGenerateColumns="false" runat="server" >
       <MasterTableView  AllowPaging="true" AutoGenerateColumns="false"> 
        <Columns>
        <telerik:GridBoundColumn DataField="Inno_ID_Key" HeaderText="userid" Visible="true">
                                    </telerik:GridBoundColumn>
       </Columns>

    </MasterTableView>
        </telerik:RadGrid>
        </div>
        <div>
        <telerik:RadAjaxLoadingPanel ID="LP1" runat="server"></telerik:RadAjaxLoadingPanel>
        
        </div>
        <div>
        <telerik:RadAjaxManager runat="server">
        <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="radgrdidemo">
        <UpdatedControls>
        
        <telerik:AjaxUpdatedControl ControlID="radgrdidemo" LoadingPanelID="LP1" />
        </UpdatedControls>

        </telerik:AjaxSetting>
        </AjaxSettings>
        </telerik:RadAjaxManager>
        </div>
        <div>
        <telerik:RadScriptManager runat="server">
        </telerik:RadScriptManager>
        </div>
        </form>

    and i am binding grid in page load 

    public partial class WebForm5 : System.Web.UI.Page
        {
            public SqlDataReader dr;
            protected void Page_Load(object sender, EventArgs e)
            {
                
                var conString = System.Configuration.ConfigurationManager.ConnectionStrings["Amscan-ProdConnectionString"];
                string strConnString = conString.ConnectionString;
                SqlConnection sqlCon = new SqlConnection(strConnString);
                sqlCon.Open();
                SqlCommand CMD = new SqlCommand(" SELECT Inno_ID_Key from DimAhiEvent ", sqlCon);

                dr = CMD.ExecuteReader();
          
                radgrdidemo.DataSource = dr;
                radgrdidemo.DataBind();
               



            }
            protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
            {
                radgrdidemo.DataSource = dr;
            }
        }
    and one thing there i see that when i am going from 1st pge to 2nd whole page loads again that i want to avoid .









  2. Answer
    Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 19 May 2014 in reply to avinash Link to this post

    Hello,

    Please try with  the below code snippet.

    public SqlDataReader dr;
    protected void Page_Load(object sender, EventArgs e)
    {
     
     
    }
    protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        var conString = System.Configuration.ConfigurationManager.ConnectionStrings["Amscan-ProdConnectionString"];
        string strConnString = conString.ConnectionString;
        SqlConnection sqlCon = new SqlConnection(strConnString);
        sqlCon.Open();
        SqlCommand CMD = new SqlCommand(" SELECT Inno_ID_Key from DimAhiEvent ", sqlCon);
     
        dr = CMD.ExecuteReader();
     
        radgrdidemo.DataSource = dr;
    }


    Thanks,
    Jayesh Goyani
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. avinash
    avinash  avatar
    9 posts
    Member since:
    Apr 2014

    Posted 19 May 2014 in reply to Jayesh Goyani Link to this post

    Hi Jayesh,

    the above solution is working perfectly but there is always a page Postback whenever we are changing the index of paging , any solution or approach for that

  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 19 May 2014 in reply to avinash Link to this post

    Hi Avinash,

    When binding the grid with NeedDataSource event you donot have to bind it again in the PageLoad. Please take a look at this documentation for more details.
    Advanced Data-binding (Using NeedDataSource Event)

    Thanks,
    Princy
  6. Answer
    Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 21 May 2014 in reply to Princy Link to this post

    Hello Avinash,

    Posting is needed in server side binding. But you can ajaxify your radgrid.

    UpdatePanel :
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                      // Your Radgrid markup code
                </ContentTemplate>
            </asp:UpdatePanel>

    RadAjaxManager: Please add this code above your radgrid.

    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadGrid1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1"></telerik:AjaxUpdatedControl>
                    </UpdatedControls>
                </telerik:AjaxSetting>
    </telerik:RadAjaxManager>


    Thanks,
    Jayesh Goyani
  7. Answer
    Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 21 May 2014 in reply to Jayesh Goyani Link to this post

    Hello,

    I have changed the ID in above code snippet.

    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="radgrdidemo">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="radgrdidemo"></telerik:AjaxUpdatedControl>
                    </UpdatedControls>
                </telerik:AjaxSetting>
    </telerik:RadAjaxManager>

    Thanks,
    Jayesh Goyani
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017