Hi!
Here is the problem: I have a radgrid with detailtable(partners and contracts).
I want to edit a contract using Editform. Every time something causes a pageload(fe: click a button on the edit form) all the contracts of the partner disappear. The edit form disappears too. There is no message like "No child records to display", all I can see is an empty row.
The Page_Load method contains the calling of the databind method of the grid.
I think this is a common and simple problem, so I wont copy my code here.
Sorry for my bad English.
Here is the problem: I have a radgrid with detailtable(partners and contracts).
I want to edit a contract using Editform. Every time something causes a pageload(fe: click a button on the edit form) all the contracts of the partner disappear. The edit form disappears too. There is no message like "No child records to display", all I can see is an empty row.
The Page_Load method contains the calling of the databind method of the grid.
I think this is a common and simple problem, so I wont copy my code here.
Sorry for my bad English.
8 Answers, 1 is accepted
0
Jayesh Goyani
Top achievements
Rank 2
answered on 09 Aug 2012, 05:11 PM
Hello,
Please check code snippet/demo.
Thanks,
Jayesh Goyani
Please check code snippet/demo.
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" OnNeedDataSource="RadGrid1_NeedDataSource"OnDetailTableDataBind="RadGrid1_DetailTableDataBind"> <MasterTableView DataKeyNames="ID,Name" CommandItemDisplay="Top"> <Columns> <telerik:GridBoundColumn DataField="ID" UniqueName="ID" HeaderText="ID"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Name" UniqueName="Name" HeaderText="Name"> </telerik:GridBoundColumn> <telerik:GridEditCommandColumn> </telerik:GridEditCommandColumn> </Columns> <DetailTables> <telerik:GridTableView> <Columns> <telerik:GridBoundColumn DataField="CID" UniqueName="CID" HeaderText="CID"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Name" UniqueName="Name" HeaderText="Name"> </telerik:GridBoundColumn> <telerik:GridEditCommandColumn> </telerik:GridEditCommandColumn> </Columns> </telerik:GridTableView> </DetailTables> </MasterTableView> </telerik:RadGrid>protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) { // Bind parent grid dynamic data = new[] { new { ID = 1, Name ="Parent"}, new { ID = 2, Name = "Parent"}, new { ID = 3, Name = "Parent"}, new { ID = 4, Name = "Parent"}, new { ID = 5, Name ="Parent"} }; RadGrid1.DataSource = data; }protected void RadGrid1_DetailTableDataBind(object sender, GridDetailTableDataBindEventArgs e) { string strId = (e.DetailTableView.ParentItem as GridDataItem).GetDataKeyValue("ID").ToString(); dynamic data = new[] { new { CID = 1, Name ="Child"+strId}, new { CID = 2, Name = "Child"+strId}, new { CID = 3, Name = "Child"+strId}, new { CID = 4, Name = "Child"+strId}, new { CID = 5, Name ="Child"+strId} }; e.DetailTableView.DataSource = data; }Thanks,
Jayesh Goyani
0
Gábor
Top achievements
Rank 1
answered on 10 Aug 2012, 02:26 PM
This is how to make a simple grid with detail table, but not the answer to my question.
0
Jayesh Goyani
Top achievements
Rank 2
answered on 10 Aug 2012, 02:31 PM
Hello,
Please create new page and try with above code snippet.
you can get your answer/result in it.
Thanks,
Jayesh Goyani
Please create new page and try with above code snippet.
you can get your answer/result in it.
Thanks,
Jayesh Goyani
0
Gábor
Top achievements
Rank 1
answered on 10 Aug 2012, 02:34 PM
OK, I will.
Please check this topic one hour later, I will post the results.
Please check this topic one hour later, I will post the results.
0
Gábor
Top achievements
Rank 1
answered on 10 Aug 2012, 03:24 PM
OK I tried it, but still not understand why my records disappear. Please tell me the reason.
0
Jayesh Goyani
Top achievements
Rank 2
answered on 10 Aug 2012, 03:28 PM
Hello,
I am binding records by below event.
you are trying to bind your grid in page_load, or your own way so...
Thanks,
Jayesh Goyani
I am binding records by below event.
Parent Grid="RadGrid1_NeedDataSource"Child Grid="RadGrid1_DetailTableDataBind"you are trying to bind your grid in page_load, or your own way so...
Thanks,
Jayesh Goyani
0
Gábor
Top achievements
Rank 1
answered on 10 Aug 2012, 03:32 PM
I changed it to your way and killed all the bindings in the Page_Load before I said I tried it.
Still doesn't work. :(
Still doesn't work. :(
0
Gábor
Top achievements
Rank 1
answered on 14 Aug 2012, 12:23 PM
UP!