Terence Pae
Top achievements
Rank 1
Terence Pae
asked on 10 Aug 2009, 04:01 PM
Hello,
I can't access the RadGrid inside the panel bar through intellisense..
| <telerik:RadGrid ID="MyConditions" runat="server" Skin="Web20" |
| AutoGenerateColumns="false" Width="450px" Height="300px" |
| OnNeedDataSource="MyConditions_NeedDataSource"> |
| <MasterTableView> |
| <Columns> |
| <telerik:GridBoundColumn HeaderText="Condition ID" DataField="ConditionId" ></telerik:GridBoundColumn> |
| <telerik:GridBoundColumn HeaderText="Condition" DataField="Condition" ></telerik:GridBoundColumn> |
| <telerik:GridBoundColumn HeaderText="From:" DataField="FromTime" ></telerik:GridBoundColumn> |
| <telerik:GridBoundColumn HeaderText="To:" DataField="ToTime" ></telerik:GridBoundColumn> |
| <telerik:GridBoundColumn HeaderText="Treatments" DataField="Treatments" ></telerik:GridBoundColumn> |
| </Columns> |
| </MasterTableView> |
| </telerik:RadGrid> |
When I try to access it in VB, it doesn't recognize it..
6 Answers, 1 is accepted
0
Accepted
Shinu
Top achievements
Rank 2
answered on 11 Aug 2009, 05:40 AM
Hi Terence,
I am not sure how you trying to access the grid placed in PanelBar ItemTemplate. You need to access to corresponding panelbar item (which RadGrid resides) and then access radgrid using FindControl method. The FindControl method provides you with a reference to any control inside any of the templates used in the RadPanelBar or any of its PanelItems. See the example that I tried.
ASPX:
VB:
Please refer following link for more details:
Accessing Nested Controls
-Shinu.
I am not sure how you trying to access the grid placed in PanelBar ItemTemplate. You need to access to corresponding panelbar item (which RadGrid resides) and then access radgrid using FindControl method. The FindControl method provides you with a reference to any control inside any of the templates used in the RadPanelBar or any of its PanelItems. See the example that I tried.
ASPX:
| <telerik:RadPanelBar ID="RadPanelBar1" runat="server"> |
| <Items> |
| <telerik:RadPanelItem runat="server" Text="Catelog" Value="Catelog"> |
| <ItemTemplate> |
| <telerik:RadGrid ID="MyGrid" runat="server"> |
| </telerik:RadGrid> |
| </ItemTemplate> |
| </telerik:RadPanelItem> |
| </Items> |
| </telerik:RadPanelBar> |
VB:
| Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) |
| Dim panelItem As RadPanelItem = DirectCast(RadPanelBar1.FindItemByText("Catelog"), RadPanelItem) |
| Dim grid As RadGrid = DirectCast(panelItem.FindControl("MyGrid"), RadGrid) |
| End Sub |
Accessing Nested Controls
-Shinu.
0
Terence Pae
Top achievements
Rank 1
answered on 11 Aug 2009, 10:49 AM
Awesome! Thank you!
0
Jeremy Pryor
Top achievements
Rank 1
answered on 29 Jan 2010, 03:54 PM
I am nesting a RadGrid inside a PanelBar and having some issues with the Sorting and Paging. Is there anythiing special that I need to do when it comes to using these features of the RadGrid inside the PanelBar.
| <telerik:RadScriptManager ID="radScriptManager1" runat="server"></telerik:RadScriptManager> |
| <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" Width="100%" |
| Height="205px"> |
| <telerik:RadPanelBar ID="RadPanelBar1" runat="server" Width="1000px"> |
| <Items> |
| <telerik:RadPanelItem Expanded="True" Text="Step 1: Report List" runat="server" Selected="true" Width="100%"> |
| <Items> |
| <telerik:RadPanelItem Value="ReportList" runat="server" Width="100%"> |
| <ItemTemplate> |
| <table id="Table1" border="0" Width="100%"> |
| <tr> |
| <td> |
| <asp:Button ID="btnNewReport" runat="server" Text="New" Visible="true" /> |
| <asp:Button ID="btnEdit" runat="server" Text="Edit" Visible="true" /> |
| <asp:Button ID="btnCopy" runat="server" Text="Copy" Visible="true" /> |
| <asp:Button ID="btnDelete" runat="server" Text="Delete" Visible ="true" /> |
| </td> |
| </tr> |
| <tr> |
| <td> |
| <telerik:RadGrid ID="RadGrid1" |
| Width="97%" |
| AllowSorting="True" |
| OnSortCommand="RadGrid1_SortCommand" |
| PageSize="15" |
| AllowPaging="True" |
| AllowMultiRowSelection="false" |
| runat="server" |
| Gridlines="None" |
| > |
| <SortingSettings SortedBackColor="LightGray" EnableSkinSortStyles="false" /> |
| <MasterTableView |
| AutoGenerateColumns="False" |
| AllowNaturalSort="false" |
| AllowMultiColumnSorting="false"> |
| <Columns> |
| <telerik:GridBoundColumn |
| DataField="Dashboard_id" |
| DataType="System.Int32" |
| Visible="false"> |
| <ItemStyle Width="0px" /> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn |
| DataField="CreatedOn" |
| DataType="System.DateTime" |
| HeaderText="Created On" |
| SortExpression="CreatedOn" |
| DataFormatString="{0:MM/dd/yyyy}" |
| visible="true" |
| UniqueName="CreatedOn"> |
| <ItemStyle Width="80px" /> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn |
| DataField="Dashboard_nm" |
| DataType="System.String" |
| HeaderText="Report Name" |
| SortExpression="Dashboard_nm" |
| visible="true" |
| UniqueName="Dashboard_nm"> |
| <ItemStyle Width="200px" /> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn |
| DataField="CreatedBy" |
| DataType="System.String" |
| HeaderText="Created By" |
| SortExpression="CreatedBy" |
| visible="true" |
| UniqueName="CreatedBy"> |
| <ItemStyle Width="100px" /> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn |
| DataField="ModifiedBy" |
| DataType="System.String" |
| HeaderText="Modified By" |
| SortExpression="ModifiedBy" |
| visible="true" |
| UniqueName="ModifiedBy"> |
| <ItemStyle Width="0px" /> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn |
| DataField="Client_id" |
| DataType="System.Int32" |
| HeaderText="" |
| SortExpression="" |
| visible="false" |
| UniqueName=""> |
| <ItemStyle Width="0px" /> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn |
| DataField="DashboardParameter_id" |
| DataType="System.Int32" |
| HeaderText="" |
| SortExpression="" |
| visible="false" |
| UniqueName=""> |
| <ItemStyle Width="0px" /> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn |
| DataField="ModifiedOn" |
| DataType="System.DateTime" |
| HeaderText="Modified On" |
| SortExpression="ModifiedOn" |
| DataFormatString="{0:MM/dd/yyyy}" |
| visible="true" |
| UniqueName="ModifiedOn"> |
| <ItemStyle Width="80px" /> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn |
| DataField="RecordState" |
| DataType="System.Byte" |
| HeaderText="" |
| SortExpression="" |
| visible="false" |
| UniqueName=""> |
| <ItemStyle Width="0px" /> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn |
| DataField="State_cd" |
| DataType="System.Int16" |
| HeaderText="" |
| SortExpression="" |
| visible="false" |
| UniqueName=""> |
| <ItemStyle Width="0px" /> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn |
| DataField="Market_id" |
| DataType="System.Int32" |
| HeaderText="" |
| SortExpression="" |
| visible="false" |
| UniqueName=""> |
| <ItemStyle Width="0px" /> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn |
| DataField="Market_dsc" |
| DataType="System.String" |
| HeaderText="" |
| SortExpression="" |
| visible="false" |
| UniqueName=""> |
| <ItemStyle Width="0px" /> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn |
| DataField="Threshold" |
| DataType="System.Byte" |
| HeaderText="" |
| SortExpression="" |
| visible="false" |
| UniqueName=""> |
| <ItemStyle Width="0px" /> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn |
| DataField="Date1_nm" |
| DataType="System.String" |
| HeaderText="" |
| SortExpression="" |
| visible="false" |
| UniqueName=""> |
| <ItemStyle Width="0px" /> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn |
| DataField="Date1Start" |
| DataType="System.DateTime" |
| HeaderText="" |
| SortExpression="" |
| DataFormatString="{0:MM/dd/yyyy}" |
| visible="false" |
| UniqueName=""> |
| <ItemStyle Width="0px" /> |
| </telerik:GridBoundColumn> |
| </Columns> |
| </MasterTableView> |
| <PagerStyle Mode="NextPrevAndNumeric" /> |
| </telerik:RadGrid> |
| </td> |
| </tr> |
| </table> |
| </ItemTemplate> |
| </telerik:RadPanelItem> |
| </Items> |
| </telerik:RadPanelItem> |
| </Items> |
| </telerik:RadPanelBar> |
| </telerik:RadAjaxPanel> |
...and the code behind:
| Protected Sub RadGrid1_SortCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridSortCommandEventArgs) |
| Dim sortExpr As New GridSortExpression() |
| Dim radGrid1 As Telerik.Web.UI.RadGrid |
| radGrid1 = DirectCast(RadPanelBar1.FindItemByValue("ReportList").FindControl("RadGrid1"), Telerik.Web.UI.RadGrid) |
| Select Case e.OldSortOrder |
| Case GridSortOrder.None |
| sortExpr.FieldName = e.SortExpression |
| sortExpr.SortOrder = GridSortOrder.Descending |
| e.Item.OwnerTableView.SortExpressions.AddSortExpression(sortExpr) |
| Exit Select |
| Case GridSortOrder.Ascending |
| sortExpr.FieldName = e.SortExpression |
| sortExpr.SortOrder = IIf(RadGrid1.MasterTableView.AllowNaturalSort, GridSortOrder.None, GridSortOrder.Descending) |
| e.Item.OwnerTableView.SortExpressions.AddSortExpression(sortExpr) |
| Exit Select |
| Case GridSortOrder.Descending |
| sortExpr.FieldName = e.SortExpression |
| sortExpr.SortOrder = GridSortOrder.Ascending |
| e.Item.OwnerTableView.SortExpressions.AddSortExpression(sortExpr) |
| Exit Select |
| End Select |
| e.Canceled = True |
| RadGrid1.Rebind() |
| End Sub |
Thanks!
JP
0
Hi Jeremy,
There is nothing special you should know or do when RadGrid is nested in RadPanelBar. However, could you please check if the your grid works properly if it is outside the RadPanelBar item so we could isolate the problem further?
Additionally, please specify how is the grid bound.
All the best,
Iana
the Telerik team
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
There is nothing special you should know or do when RadGrid is nested in RadPanelBar. However, could you please check if the your grid works properly if it is outside the RadPanelBar item so we could isolate the problem further?
Additionally, please specify how is the grid bound.
All the best,
Iana
the Telerik team
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Jeremy Pryor
Top achievements
Rank 1
answered on 04 Feb 2010, 04:27 PM
My problem is not necessarily with the rad grid, it is the Panel Bar when the grid is nested in the PanelBar. When the grid initially loads, the Panel item collapses fine, but if I click on sorting or paging in the rad grid, then try and collapse the Panel Item, it will not collapse.
Thanks,
JP
Thanks,
JP
0
Hi Jeremy,
Could you please try sending a sample project illustrating the unexpected behavior you are facing, or at least share the problematic page code, so I could perform further testing and see what could have gone wrong there?
Looking forward your reply,
Iana
the Telerik team
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
Could you please try sending a sample project illustrating the unexpected behavior you are facing, or at least share the problematic page code, so I could perform further testing and see what could have gone wrong there?
Looking forward your reply,
Iana
the Telerik team
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.