Codebehind version of the Master/Detail SelectedValue sample

8 posts, 0 answers
  1. CSurieux
    CSurieux avatar
    465 posts
    Member since:
    Jan 2007

    Posted 15 Jan 2010 Link to this post

    Hello,

    I need to build same code as in this sample but I have no declarative datasources.
    Is there somewhere some samples off a full code behind version.

    How to have the master grid triggering an ajax event to rebind details when a row is changed, how to select first row and, if exists, first details row.


    Thanks for help.
    CS
  2. CSurieux
    CSurieux avatar
    465 posts
    Member since:
    Jan 2007

    Posted 15 Jan 2010 Link to this post

    I also noticed that the Telerik sample doesn't work perfectly: when you change a row in the inner table, the first detail is updated but, as its first row is not selected, the second detail grid is not updated and presents data related to another record: very bad!

    The second level detail grid should be cleared if no row is selected in its master: how to do this ?

    I would also appreciate to have keyboard working: when changing current row with keybord the details should upgrade.

    Thanks Telerik for Help.

    CS
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mira
    Admin
    Mira avatar
    1124 posts

    Posted 20 Jan 2010 Link to this post

    Hello Christian,

    I have prepared a sample project based on the Master/Detail Grids demo and fulfilling your requirements.
    You can find it attached to this message.
    I hope this helps.

    Sincerely yours,
    Mira
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. Vasssek
    Vasssek avatar
    143 posts
    Member since:
    Aug 2010

    Posted 12 Apr 2011 Link to this post

    Hello,

    do you have an example of master detail which is created with code behind technique ?

    Best regards

    Vasssek
  6. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 12 Apr 2011 Link to this post

    Hello Vasssek,

    Check out the following demo which demonstrates how to programmatically build hierarchical structures with Telerik RadGrid.
    Grid / Creating Hierarchy Programmatically

    Thanks,
    Shinu.
  7. Vasssek
    Vasssek avatar
    143 posts
    Member since:
    Aug 2010

    Posted 12 Apr 2011 Link to this post

    Hello,

    I feel sorry that I bother you again, but your link is suited for nested grids :-((. 

    The grids in my case are actually not nested.  There is a RadGrid1 and RadGrid2 that are related to each other in a Master/Detail relationship...

    I need to achieve similar functionality like in this example http://demos.telerik.com/aspnet-ajax/grid/examples/programming/selectedvalue/defaultcs.aspx, with static radgrids declaration in aspx page, but filtering the records in the second grid according to the selection in the first should be processed in code behind (C#). I know how to work with OnNeedDataSource, but how to trap selected item from master RadGrid1 via enablepostbackonrowclick event ?

    Thank you

    Vasssek
  8. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 18 Apr 2011 Link to this post

    Hello Vasssek,

    You can attach 'OnSelectedIndexChanged' event to first RadGrid to achieve this.Then in that event handler call Rebind method of second grid which in turn call the NeedDataSource event of second grid.Then in NeedDataSource event populate RadGrid2 based on the selected row of first grid. Sample code is given below.

    ASPX:
    <telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource"
        OnSelectedIndexChanged="RadGrid1_SelectedIndexChanged" >
        <MasterTableView DataKeyNames="CustomerID">
            <Columns>
               .  .  .  .  .
            </Columns>
        </MasterTableView>
        <ClientSettings Selecting-AllowRowSelect="true" EnablePostBackOnRowClick="true">
        </ClientSettings>
    </telerik:RadGrid>
     
    <telerik:RadGrid ID="RadGrid2" runat="server" OnNeedDataSource="RadGrid2_NeedDataSource">
        .  .   .   .  .
    </telerik:RadGrid>

    C#:
    protected void RadGrid1_SelectedIndexChanged(object sender, EventArgs e)
      {
         RadGrid2.Rebind();
      }
     
    protected void RadGrid2_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
      {
         //populate second grid(RadGrid2) based on selected row of RadGrid1
      }

    -Shinu.
  9. Vasssek
    Vasssek avatar
    143 posts
    Member since:
    Aug 2010

    Posted 18 Apr 2011 Link to this post

    Hello,

    thank you for your explanation. It's exactly what I was looking for :)).

    In combination with this link http://www.telerik.com/community/forums/aspnet-ajax/grid/how-to-get-selected-row-from-codebehind-without-checkbox-selection-no-client-side-script.aspx , I'm able to create relation between two radgrids from code behind...

    Best regards

    Vasssek
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017