This is a migrated thread and some comments may be shown as answers.

Codebehind version of the Master/Detail SelectedValue sample

7 Answers 128 Views
Grid
This is a migrated thread and some comments may be shown as answers.
CSurieux
Top achievements
Rank 2
CSurieux asked on 15 Jan 2010, 04:38 PM
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

7 Answers, 1 is accepted

Sort by
0
CSurieux
Top achievements
Rank 2
answered on 15 Jan 2010, 04:55 PM
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
0
Mira
Telerik team
answered on 20 Jan 2010, 11:27 AM
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.
0
Vasssek
Top achievements
Rank 1
answered on 12 Apr 2011, 09:47 AM
Hello,

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

Best regards

Vasssek
0
Shinu
Top achievements
Rank 1
answered on 12 Apr 2011, 10:46 AM
Hello Vasssek,

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

Thanks,
Shinu.
0
Vasssek
Top achievements
Rank 1
answered on 12 Apr 2011, 02:01 PM
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
0
Shinu
Top achievements
Rank 1
answered on 18 Apr 2011, 09:07 AM
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.
0
Vasssek
Top achievements
Rank 1
answered on 18 Apr 2011, 09:10 PM
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
Tags
Grid
Asked by
CSurieux
Top achievements
Rank 2
Answers by
CSurieux
Top achievements
Rank 2
Mira
Telerik team
Vasssek
Top achievements
Rank 1
Shinu
Top achievements
Rank 1
Share this question
or