I have a project in which I have a hierarchical RadGrid contained within a UserControl (usrAccountOverview.ascx). There is an aspx page that dynamically loads a number of these UserControls based upon which option a user selects in a DropDownList. The RadGrid binds data just fine at the top of the hierarchy, and if you expand one top-level item in the hierarchy binding works fine within the DetailTable as well. However, if the page posts back, none of the previously bound data reappears in any expanded DetailTables.
Here is the declarative code for the RadGrid
I am loading the UserControls in the Page_Init method of the aspx page and binding them as in the following:
Is there some way of getting this to work?
Thanks,
Brian
Here is the declarative code for the RadGrid
| <telerik:RadGrid ID="rgMonthly" runat="server" GridLines="None" OnColumnCreated="rgMonthly_ColumnCreated" |
| OnDetailTableDataBind="rgMonthly_DetailTableDataBind" OnItemDataBound="rgMonthly_ItemDataBound" |
| OnNeedDataSource="rgMonthly_NeedDataSource"> |
| <MasterTableView DataKeyNames="GroupID"> |
| <DetailTables> |
| <telerik:GridTableView Width="100%" runat="server" DataKeyNames="GroupID"> |
| <ParentTableRelation> |
| <telerik:GridRelationFields DetailKeyField="GroupID" MasterKeyField="GroupID" /> |
| </ParentTableRelation> |
| </telerik:GridTableView> |
| </DetailTables> |
| </MasterTableView> |
| </telerik:RadGrid> |
I am loading the UserControls in the Page_Init method of the aspx page and binding them as in the following:
| protected void Page_Init(object source, System.EventArgs e) |
| { |
| BindSelectedInfo(); |
| } |
| protected void BindSelectedInfo() |
| { |
| try |
| { |
| DTSelectedAccts = TAAcctPi.GetData(Int32.Parse(Session["id"].ToString())); |
| for (int i = 0; i < 1; i++) |
| { |
| dsAccountProjections.dtAcctPiRow SelectedAcct = DTSelectedAccts[i]; |
| usrAccountOverview AccountOverview = (usrAccountOverview)LoadControl("~/usrAccountOverview.ascx"); |
| AccountOverview.ID = "usr" + SelectedAcct.SlAcct6Num; |
| AccountOverview.Acct.AcctNum = SelectedAcct.SlAcct6Num; |
| AccountOverview.PullAcctInfo(); |
| pnlHolder.Controls.Add(AccountOverview); |
| } |
| } |
| catch (Exception ex) |
| { |
| } |
| } |
| protected void rgMonthly_NeedDataSource(object source, GridNeedDataSourceEventArgs e) |
| { |
| if (!e.IsFromDetailTable) |
| { |
| rgMonthly.DataSource = DMonthlyExpenditures.GetMonthlyExpendituresByGroup(_Acct.AcctNum, firstMonthID, lastMonthID, lastMonthID); |
| } |
| } |
| protected void rgMonthly_DetailTableDataBind(object source, GridDetailTableDataBindEventArgs e) |
| { |
| GridDataItem parentItem = e.DetailTableView.ParentItem; |
| DataTable dtBind = DMonthlyExpenditures.GetMonthlyExpendituresBySubAcct(_Acct.AcctNum, firstMonthID, lastMonthID, lastMonthID, Int32.Parse(parentItem["GroupID"].Text)); |
| if (dtBind.Rows.Count > 0) e.DetailTableView.DataSource = dtBind; |
| } |
Is there some way of getting this to work?
Thanks,
Brian