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

Only first row RadButton in RadGrid can fire

4 Answers 118 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Roland
Top achievements
Rank 1
Roland asked on 05 Dec 2013, 05:24 AM
Only first row RadButton in RadGrid can fire, please help.
Thanks

In Grid:
<telerik:GridTemplateColumn HeaderStyle-Width="20%" UniqueName="ButtonSet">
    <ItemTemplate>
        <telerik:RadButton runat="server" id="Button1" CommandName="Action1" AutoPostBack="true" CausesValidation="false" OnClientClicked="clientclick"></telerik:RadButton>
        <telerik:RadButton runat="server" id="Button2" CommandName="Action2" AutoPostBack="true"></telerik:RadButton>
    </ItemTemplate>
</telerik:GridTemplateColumn>

In RadAjaxManager:
<telerik:AjaxSetting AjaxControlID="Button1
"
>
    <UpdatedControls>
        <telerik:AjaxUpdatedControl ControlID="label" LoadingPanelID="RadAjaxLoadingPanel1" />
    </UpdatedControls>
</telerik:AjaxSetting>

if (e.CommandName == "Action1")
{
    //do sth
}
else if (e.CommandName == "Action1")
{
    //do sth
}










4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 05 Dec 2013, 05:56 AM
Hi Roland,

 I'm not clear about your requirement. I see that you have two buttons in GridTemplateColumn, Button1 and Button2 with CommandName, Action1 and Action2 respectively. In the ItemCommand if you want to access these buttons you can use the CommandName, I notice that you have used the same CommandName for the condition please try as below to have both buttons firing.

C#:
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
 {
    if (e.CommandName == "Action1")
    {
       //Do something
    }
    else if (e.CommandName == "Action2")
    {
        //Do something
    }
 }

Thanks,
Princy
0
Roland
Top achievements
Rank 1
answered on 05 Dec 2013, 07:43 AM
hi, thanks for reply

O..sorry, I forgot to make (e.CommandName == "Action1") which is on ItemCommand already in the grid. 

<telerik:RadGrid ID="RadGrid" GridLines="None" runat="server" AllowAutomaticDeletes="True" AllowAutomaticInserts="True"
                    OnItemDeleted="RadGrid_ItemDeleted" OnItemInserted="RadGrid_ItemInserted" OnItemUpdated="RadGrid_ItemUpdated"
                    OnBatchEditCommand="RadGrid_BatchEditCommand"
                    DataSourceID="WebMethod" OnItemCommand="RadGrid_ItemCommand"
                    AllowAutomaticUpdates="True" AllowPaging="True" AutoGenerateColumns="False" Width="100%" CellSpacing="0">

When I add the following code in the aspx

<telerik:AjaxSetting AjaxControlID="RadGrid">
 <UpdatedControls>
      <telerik:AjaxUpdatedControl ControlID="RadGrid" UpdatePanelCssClass=""></telerik:AjaxUpdatedControl>
 </UpdatedControls>
</telerik:AjaxSetting>

It can fire only the first row, the second row will no response.
I checked in chrome, it post to server already. but no change for the label when click the button.

If I do not add AjaxControlID="RadGrid" to itself.
It will fire the first row with the ajax and without refresh the whole page thus it works.
The second row for the post back and refresh the whole page.

Thanks


0
Princy
Top achievements
Rank 2
answered on 06 Dec 2013, 03:38 AM
Hi Roland,

I guess your Grid is Ajaxified and you have a label somewhere outside the RadGrid. There are two buttons inside a TemplateColumn, and on its click, the Label should be updated. Please add the LabelID to the UpdateControls as follows:

ASPX:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RadGrid">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadGrid" UpdatePanelCssClass=""></telerik:AjaxUpdatedControl>
                <telerik:AjaxUpdatedControl ControlID="Label1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>

Thanks,
Princy
0
Roland
Top achievements
Rank 1
answered on 06 Dec 2013, 04:45 AM
Thanks for replay.
It is not work but I fixed the issue.

add the following code and it works
<telerik:AjaxSetting AjaxControlID="RadGrid">
    <UpdatedControls>
        <telerik:AjaxUpdatedControl ControlID="ButtonControl" />
    </UpdatedControls>
</telerik:AjaxSetting>


Thanks
Tags
Grid
Asked by
Roland
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Roland
Top achievements
Rank 1
Share this question
or