Situation,
I have a hierarchy grid where in the nested grid a link pops up a modal pop-up so the user can edit all of the contents of the object, the nested grid only shows a selected portion. upon saving all is good except the nested grid, I cannot seem to figure out how to refresh it, unless I reload the entire page which I guess would work but not preferable. would like to just refresh the nested grid but will settle for the whole grid if need be.
Aspx Code:
C# Code:
thanks,
jms
I have a hierarchy grid where in the nested grid a link pops up a modal pop-up so the user can edit all of the contents of the object, the nested grid only shows a selected portion. upon saving all is good except the nested grid, I cannot seem to figure out how to refresh it, unless I reload the entire page which I guess would work but not preferable. would like to just refresh the nested grid but will settle for the whole grid if need be.
Aspx Code:
<asp:UpdatePanel ID="upnlGrid" runat="server" UpdateMode="Conditional"> |
<ContentTemplate> |
<telerik:RadGrid ID="UnitList" runat="server" AutoGenerateColumns="False" |
DataSourceID="UnitDataSource" GridLines="None" |
Skin="Windows7"> |
<MasterTableView datakeynames="Id" datasourceid="UnitDataSource"> |
<DetailTables> |
<telerik:GridTableView runat="server" DataKeyNames="Id" |
CssClass="GridBackground"> |
<RowIndicatorColumn> |
<HeaderStyle Width="20px" /> |
</RowIndicatorColumn> |
<ExpandCollapseColumn> |
<HeaderStyle Width="20px" /> |
</ExpandCollapseColumn> |
<Columns> |
<telerik:GridTemplateColumn DataField="Title" HeaderText="Title" |
UniqueName="LTitle"> |
<ItemTemplate> |
<asp:LinkButton ID="lbtnLTitle" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "Id")%>' runat="server" OnClick="lbtnLTitle_Click" Text='<%# DataBinder.Eval(Container.DataItem, "Title") %>'></asp:LinkButton> |
</ItemTemplate> |
</telerik:GridTemplateColumn> |
<telerik:GridBoundColumn DataField="Presenter" HeaderText="Presenter" |
UniqueName="LPresenter"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="Location" HeaderText="Location" |
UniqueName="LLocation"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="Hours" HeaderText="Hours" |
UniqueName="LHours"> |
</telerik:GridBoundColumn> |
<telerik:GridCheckBoxColumn DataField="IsActive" DataType="System.Boolean" |
HeaderText="Active" UniqueName="LIsActive"> |
</telerik:GridCheckBoxColumn> |
</Columns> |
</telerik:GridTableView> |
</DetailTables> |
<RowIndicatorColumn> |
<HeaderStyle Width="20px"></HeaderStyle> |
</RowIndicatorColumn> |
<ExpandCollapseColumn visible="True"> |
<HeaderStyle Width="20px"></HeaderStyle> |
</ExpandCollapseColumn> |
<Columns> |
<telerik:GridTemplateColumn DataField="Title" HeaderText="Title" |
UniqueName="UTitle"> |
<ItemTemplate> |
<asp:LinkButton ID="lbtnUTitle" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "Id")%>' runat="server" OnClick="lbtnUTitle_Click" Text='<%# DataBinder.Eval(Container.DataItem, "Title") %>'></asp:LinkButton> |
</ItemTemplate> |
</telerik:GridTemplateColumn> |
<telerik:GridBoundColumn DataField="OfferDept" HeaderText="Offer Dept." |
UniqueName="UOfferDept"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="Semester" HeaderText="Semester" |
UniqueName="USemester"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="Type" HeaderText="Type" UniqueName="UType"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="StudentVuNetId" HeaderText="Student Id" |
UniqueName="UStudentVuNetId"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="Hours" HeaderText="Hours" |
UniqueName="UHours"> |
</telerik:GridBoundColumn> |
<telerik:GridCheckBoxColumn DataField="IsActive" DataType="System.Boolean" |
HeaderText="Active" UniqueName="UIsActive"> |
</telerik:GridCheckBoxColumn> |
</Columns> |
</MasterTableView> |
</telerik:RadGrid> |
<asp:ObjectDataSource ID="UnitDataSource" runat="server" |
SelectMethod="GetAllUnits" |
TypeName="Vanderbilt.CpmmProg.CommonUtils.UnitManagement"> |
</asp:ObjectDataSource> |
</ContentTemplate> |
</asp:UpdatePanel> |
C# Code:
protected void Page_Load(object sender, EventArgs e) |
{ |
//attach the event to build the nested grid |
UnitList.DetailTableDataBind += new GridDetailTableDataBindEventHandler(UnitList_DetailTableDataBind); |
if (!Page.IsPostBack) |
{ |
//do some stuff not related to grid at all |
} |
} |
protected void UnitList_DetailTableDataBind(object source, GridDetailTableDataBindEventArgs e) |
{ |
int unitId = (int)e.DetailTableView.ParentItem.GetDataKeyValue("Id"); |
e.DetailTableView.DataSource = UnitManagement.GetUnitLectures(unitId); |
} |
protected void lbtnLTitle_Click(object sender, EventArgs e) |
{ |
int Id = Int32.Parse(((LinkButton)sender).CommandArgument.ToString().Trim()); |
//TODO Get data for lecture, populate the updatePanel for editing lectures |
Lecture lec = LectureManagement.GetLecture(Id); |
tbTitle.Text = lec.Title; |
tbPresenter.Text = lec.Presenter; |
tbLocation.Text = lec.Location; |
tbHours.Text = lec.Hours.ToString(); |
tbCourseAdminVuNetId.Text = lec.CourseAdminVuNetId; |
rdtpTime.SelectedDate = lec.DateAndTime; |
hfEditLecId.Value = lec.Id.ToString(); |
cbIsActive.Checked = lec.IsActive; |
//TODO show modal popup. |
hfEditLectureDummy_ModalPopupExtender.Show(); |
} |
protected void lbtnUTitle_Click(object sender, EventArgs e) |
{ |
//redirect to another page |
} |
protected void btnEditCancel_Click(object sender, EventArgs e) |
{ |
//hide the modal popup |
hfEditLectureDummy_ModalPopupExtender.Hide(); |
} |
protected void btnEditSave_Click(object sender, EventArgs e) |
{ |
//get the lecture |
//save the lecture to persistence |
//hide modal popup |
hfEditLectureDummy_ModalPopupExtender.Hide(); |
//update the updatepanel |
upnlGrid.Update(); |
} |
thanks,
jms