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

problem with OnItemCommand

2 Answers 134 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Krzysztof
Top achievements
Rank 2
Krzysztof asked on 24 Jul 2008, 07:47 AM
Hello,

I have a problem when firing an event on clicking a button in a grid. What I want to do is visualize a asp panel when clicking the button. My Rad Grid looks like this

            <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" Width="100%" Skin="Default2006"  
            AllowSorting="True" PageSize="5" ShowStatusBar="true" ShowFooter="True"  
            AllowPaging="True" GridLines="None" OnSortCommand="RadGrid1_SortCommand"  
            OnPageIndexChanged="RadGrid1_PageIndexChanged" OnItemDataBound="RadGrid1_ItemDataBound" OnItemCommand="RadGrid1_ItemCommand"
                 
                <PagerStyle Mode="NextPrevAndNumeric" /> 
                <MasterTableView Width="100%" AutoGenerateColumns="false" ShowFooter="True" TableLayout="Auto"
                      
                     <Columns> 
                         
                        <telerik:GridTemplateColumn> 
                            <HeaderTemplate> 
                                <asp:LinkButton runat="server" ID="lbParentDir" CommandName="_parent" CommandArgument='<%# ViewState["parentId"] %>' Text="^..." /> 
                            </HeaderTemplate> 
                            <ItemTemplate> 
                                <asp:LinkButton runat="server" ID="lbTitle" CommandName="_children" Text='<%# Bind("title") %>' CommandArgument='<%# Bind("id") %>' /> 
                            </ItemTemplate> 
                        </telerik:GridTemplateColumn>  
                        
                        (...) 
 
                        <telerik:GridTemplateColumn > 
                            <ItemTemplate> 
                               <asp:Button runat="server" CssClass="button" ID="btView" CommandArgument='<%# Bind("id") %>' CommandName="_view" Text="View"/> 
                            </ItemTemplate> 
                        </telerik:GridTemplateColumn> 
                    </Columns>  
 
               </MasterTableView> 
            </telerik:RadGrid> 

and the code behind where the event fires is:

    protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e) 
    { 
        if (e.CommandName == "_view") 
        { 
            int id = Convert.ToInt32(e.CommandArgument); 
            ViewState["id"] = id; 
 
            panelNodeView.Visible = true
        } 
    } 
 

The problem is that the paneNodeView does not appear on postback. While debbuging everything looks fine. The paneNodeView.Visible is set to true, but it doesn't show. This worked well when using the MS Grid. Is there a difference in the RadGrid behaviour that I'm not aware of. Please fill me in.

Thanks,
Chris

2 Answers, 1 is accepted

Sort by
0
Krzysztof
Top achievements
Rank 2
answered on 24 Jul 2008, 08:02 AM
I "solved" the problem by removing the RadAjaxManager. Which looked like this:

            <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
                <AjaxSettings> 
                    <telerik:AjaxSetting AjaxControlID="RadGrid1"
                        <UpdatedControls> 
                            <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> 
                        </UpdatedControls> 
                    </telerik:AjaxSetting> 
                </AjaxSettings> 
            </telerik:RadAjaxManager> 

Is there a way to visualize the panel without removing the RadAjaxManager. I still have the RadAjaxPanel on my page, so I'm not sure how much the RadAjaxManager helps with performence.

Cheers,
Chris
0
Accepted
Veli
Telerik team
answered on 24 Jul 2008, 12:30 PM
Hello Krzysztof,

Please note that the RadAjaxManager is set up to ajaxify only RadGrid. If you need RadGrid to update a Panel element, you will need to have RadAjaxManager specify that RadGrid can ajaxify also the Panel by adding another updated control property to the settings:

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
    <AjaxSettings> 
        <telerik:AjaxSetting AjaxControlID="RadGrid1"
            <UpdatedControls> 
                <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" /> 
                <telerik:AjaxUpdatedControl ControlID="panelNodeView" /> 
            </UpdatedControls> 
        </telerik:AjaxSetting> 
    </AjaxSettings> 
</telerik:RadAjaxManager> 


Regards,
Veli
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Krzysztof
Top achievements
Rank 2
Answers by
Krzysztof
Top achievements
Rank 2
Veli
Telerik team
Share this question
or