Hello,
I have 2 radgrids, each one inside a .ascx control. Each control is inside a RadPageView on the same .aspx page. When I delete a record from one radgrid, I need the other one to refresh with the correct information. (basically parent child relation between the two grids) How can I update the datasource on the child radgrid?
Thanks
I have 2 radgrids, each one inside a .ascx control. Each control is inside a RadPageView on the same .aspx page. When I delete a record from one radgrid, I need the other one to refresh with the correct information. (basically parent child relation between the two grids) How can I update the datasource on the child radgrid?
Thanks
2 Answers, 1 is accepted
0
Accepted
Shinu
Top achievements
Rank 2
answered on 07 Aug 2009, 07:49 AM
Hi Zed,
I guess you are having difficulty in accessing the RadGrid from the UserControl which is in the other PageView. If so you may try the sample code which I tried on my end.
ASPX:
Orders.ascx:
OrderDetail.ascx:
Order.ascx.cs:
Thanks
Shinu
I guess you are having difficulty in accessing the RadGrid from the UserControl which is in the other PageView. If so you may try the sample code which I tried on my end.
ASPX:
| <telerik:RadTabStrip ID="RadTabStrip1" runat="server" MultiPageID="RadMultiPage1" > |
| <Tabs> |
| <telerik:RadTab Text="Tab1" PageViewID="RadPageView1" ></telerik:RadTab> |
| <telerik:RadTab Text="Tab2" PageViewID="RadPageView2" ></telerik:RadTab> |
| </Tabs> |
| </telerik:RadTabStrip> |
| <br /> |
| <telerik:RadMultiPage ID="RadMultiPage1" runat="server"> |
| <telerik:RadPageView ID="RadPageView1" runat="server" Width="100%"> |
| <uc2:Order id="Order1" runat="server"></uc2:Order> |
| </telerik:RadPageView> |
| <telerik:RadPageView ID="RadPageView2" runat="server" Width="100%"> |
| <uc3:OrderDetails id="OrderDetails1" runat="server"></uc3:OrderDetails> |
| </telerik:RadPageView> |
| </telerik:RadMultiPage><br /> |
Orders.ascx:
| <%@ Control Language="C#" AutoEventWireup="true" CodeFile="Order.ascx.cs" |
| Inherits="Order" %> |
| <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> |
| <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthWindConnectionString %>" |
| SelectCommand="SELECT [OrderID], [ProductID], [UnitPrice] FROM [OrderDetails]"></asp:SqlDataSource> |
| <telerik:RadGrid ID="OrderGrid" runat="server" AutoGenerateEditColumn="true" DataSourceID="SqlDataSource1" AllowPaging="true" PageSize="5" GridLines="None" OnDeleteCommand="OrderGrid_DeleteCommand" > |
| <MasterTableView CellSpacing="-1" DataSourceID="SqlDataSource1"> |
| <Columns> |
| <telerik:GridButtonColumn CommandName="Delete" Text="Delete" ></telerik:GridButtonColumn> |
| </Columns> |
| </MasterTableView> |
| </telerik:RadGrid> |
OrderDetail.ascx:
| <%@ Control Language="C#" AutoEventWireup="true" CodeFile="OrderDetails.ascx.cs" Inherits="OrderDetails" %> |
| <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> |
| <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthWindConnectionString %>" |
| SelectCommand="SELECT [OrderID], [CustomerID], [EmployeeID] FROM [Orders]"></asp:SqlDataSource> |
| <telerik:RadGrid ID="DetailsGrid" runat="server" AutoGenerateEditColumn="true" DataSourceID="SqlDataSource1" AllowPaging="true" PageSize="5" GridLines="None"> |
| <MasterTableView CellSpacing="-1" DataSourceID="SqlDataSource1"> |
| <Columns> |
| <telerik:GridButtonColumn CommandName="Delete" Text="Delete" ></telerik:GridButtonColumn> |
| </Columns> |
| </MasterTableView> |
| </telerik:RadGrid> |
Order.ascx.cs:
| protected void OrderGrid_DeleteCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) |
| { |
| //Delete Query |
| // to access the Grid in the other usercontrol which is in the other PageView |
| RadGrid detailsGrid = (RadGrid)this.Page.FindControl("OrderDetails1").FindControl("DetailsGrid"); |
| // update the detailsGrid data |
| detailsGrid.MasterTableView.Rebind(); |
| } |
Thanks
Shinu
0
Zed
Top achievements
Rank 1
answered on 20 Aug 2009, 08:14 PM
I found a better way that is not as complicated using a delegate and then subscribing to the update event.