This is a migrated thread and some comments may be shown as answers.

how to rebind radgrid within a panelbar from button

1 Answer 137 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
mac
Top achievements
Rank 1
mac asked on 28 Nov 2008, 05:02 AM
hi. I have an issue that I can't seem to work around. I have a panelbar (pb1) on main.ascx. within pb1 i have two user controls each holding a radgrid ctlr1, and ctrl2 , respectively rg1 and rg2. I need a method to rebind rg1 and rg2 at the same time. For some reason I can't reference controls within the panelbar? What I was hoping to do was put a button on main.ascx, and using ajax manager control the two grids that way. This does work if I put a rg1.mastertableview.rebind()  in the rg1_prerender event. the problem though is obvious that every time i call an action on the grid, it rebinds, so that mean I can't collapse any grouped items. 
I'm pretty rookie at this type of thing so apologies if this should be very basic. my code is below for a basic setup
PS: I want to use a button to initiate the call as I am clicking it from a radwindow javascript.
note: sample is
main.ascx
        <asp:Button ID="Button1" runat="server" Text="Button" /><br /> 
        <br /> 
        <telerik:radpanelbar id="RadPanelBar1" runat="server" width="100%">  
<CollapseAnimation Type="None" Duration="100"></CollapseAnimation> 
<Items> 
<telerik:RadPanelItem runat="server" Text="Root RadPanelItem1" Expanded="True"><Items> 
<telerik:RadPanelItem runat="server" Text="child"><ItemTemplate> 
   
   <telerik:RadAjaxPanel runat="server" ID="rap1" > 
         
            <uc1:ctrl1 ID="Ctrl1_1" runat="server" /> 
          
   </telerik:RadAjaxPanel> 
</ItemTemplate> 
</telerik:RadPanelItem> 
</Items> 
</telerik:RadPanelItem> 
</Items> 
 
<ExpandAnimation Type="None" Duration="100"></ExpandAnimation> 
</telerik:radpanelbar> 
      
    </div> 
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">  
            <AjaxSettings> 
                <telerik:AjaxSetting AjaxControlID="Button1">  
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="Ctrl1_1" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting> 
            </AjaxSettings> 
        </telerik:RadAjaxManager> 
 


ctrl1 .ascx
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" 
    GridLines="None" ShowStatusBar="True">  
    <MasterTableView DataKeyNames="testid" DataSourceID="SqlDataSource1">  
        <GroupByExpressions> 
        <telerik:GridGroupByExpression> 
        <SelectFields> 
        <telerik:GridGroupByField FieldName="fname" FieldAlias="fname" FormatString="" HeaderText="" /> 
        </SelectFields> 
        <GroupByFields> 
        <telerik:GridGroupByField FieldName="fname" FieldAlias="fname" FormatString="" HeaderText="" /> 
        </GroupByFields> 
        </telerik:GridGroupByExpression> 
        </GroupByExpressions> 
        <Columns> 
            <telerik:GridBoundColumn DataField="testid" DataType="System.Int32" HeaderText="testid" 
                ReadOnly="True" SortExpression="testid" UniqueName="testid">  
            </telerik:GridBoundColumn> 
            <telerik:GridBoundColumn DataField="fname" HeaderText="fname" SortExpression="fname" 
                UniqueName="fname">  
            </telerik:GridBoundColumn> 
            <telerik:GridBoundColumn DataField="thedate" UniqueName="thedate" /> 
              
        </Columns> 
    </MasterTableView> 
    <FilterMenu EnableTheming="True">  
        <CollapseAnimation Duration="200" Type="OutQuint" /> 
    </FilterMenu> 
</telerik:RadGrid><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:4ConnectionString %>" 
    SelectCommand="SELECT  fname,testid,getdate() as thedate FROM [testtable]"></asp:SqlDataSource> 
 

ctrl1.ascx.vb

 

Protected Sub RadGrid1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadGrid1.PreRender

 

RadGrid1.Rebind()

 

End Sub

 

1 Answer, 1 is accepted

Sort by
0
Paul
Telerik team
answered on 28 Nov 2008, 08:28 AM
Hi Mac,

I think it will be best if you can open a support ticket and send us a simple running project (incl. CSS, images, skins, DB backup if needed and so on) demonstrating the problem (and step-by-step instructions on doing so). In that way we can reproduce and pinpoint the problems you're facing on our side, understand the logic of your application and provide a solution.

Thanks beforehand for your patience and cooperation,
Paul
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
PanelBar
Asked by
mac
Top achievements
Rank 1
Answers by
Paul
Telerik team
Share this question
or