Panelbar and Grid Issue

3 posts, 0 answers
  1. Sahar
    Sahar avatar
    5 posts
    Member since:
    Sep 2013

    Posted 07 Oct 2013 Link to this post

    i wanna when click on the item in radpanelbar to load grid according to this item but if i use paging or any thing in the grid require to click on this item again .
    how can i solve this issue plz

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

    Posted 08 Oct 2013 Link to this post

    Hi Sahar,

    In order to operate advanced features like Paging in RadGrid the better approach is to use NeedDataSource as follows.

    <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="true" AutoGenerateColumns="true"
        PageSize="4" OnNeedDataSource="RadGrid1_NeedDataSource" OnPageIndexChanged="RadGrid1_PageIndexChanged">
    <telerik:RadPanelBar ID="RadPanelBar1" runat="server" DataFieldID="CategoryID" DataSourceID="SqlDataSource1"
        DataTextField="CategoryID" OnItemClick="RadPanelBar1_ItemClick">
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
        SelectCommand="SELECT top 10 [CategoryID], [CategoryName], [Description] FROM [Categories]">

    protected void RadPanelBar1_ItemClick(object sender, Telerik.Web.UI.RadPanelBarEventArgs e)
        String connectionstring = WebConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString;
        SqlConnection sqlconn = new SqlConnection(connectionstring);
        DataTable dt = new DataTable();
        string selectQuery="select * from Products where CategoryID ="+RadPanelBar1.SelectedItem.Text+"";
        SqlDataAdapter dr = new SqlDataAdapter(selectQuery, sqlconn);
        ViewState["dt"] = dt;
        RadGrid1.DataSource = dt;
    protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        DataTable dt = (DataTable)ViewState["dt"];
        RadGrid1.DataSource = dt;

  3. Sahar
    Sahar avatar
    5 posts
    Member since:
    Sep 2013

    Posted 08 Oct 2013 Link to this post

    it works well .... thanks Princy
Back to Top