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

Is it possible to add CommandName to radiobotton?

2 Answers 82 Views
Grid
This is a migrated thread and some comments may be shown as answers.
courtney shoell
Top achievements
Rank 1
courtney shoell asked on 26 Sep 2013, 12:20 PM
hi,

I am using telerik radgrid in my application  hierarchical model. in detailtables i have one  GridTableView. in the GridTableView i have a GridTemplateColumn in which i have two radio buttons and one textbox. when user enters a value in the textbox and click radio button it should fill all the other textboxes  of the row edited or inserted based on some calculation.

The design as follows.
Please advice me how to work ?
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" Skin="Black" OnItemDataBound="RadGrid1_ItemDataBound" OnItemCreated="RadGrid1_ItemCreated"
    AllowSorting="True" AllowMultiRowSelection="False" OnItemCommand="RadGrid1_ItemCommand" AutoGenerateEditColumn="false"
    OnDetailTableDataBind="RadGrid1_DetailTableDataBind" OnNeedDataSource="RadGrid1_NeedDataSource" OnInsertCommand="RadGrid1_InsertCommand"
    OnPreRender="RadGrid1_PreRender" >
 
    <MasterTableView DataKeyNames="TempAccountsId" ShowFooter="true" TableLayout="Fixed" AllowMultiColumnSorting="True"  EditMode="InPlace" >
        <DetailTables>
            <telerik:GridTableView DataKeyNames="CleaningId" CommandItemDisplay="Top"  TableLayout="Fixed" Name="Cleaning" ShowFooter="true" EditMode="InPlace" AllowAutomaticUpdates="false">
                <Columns>
                    <telerik:GridTemplateColumn Visible="false">
                        <ItemTemplate>
                            <asp:Label ID="lblCleaningId" runat="server" Text='<%#Eval("CleaningId") %>'></asp:Label>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridEditCommandColumn ButtonType="ImageButton" HeaderText="Edit" UniqueName="Edit" ItemStyle-Width="25px" HeaderStyle-HorizontalAlign="Center"
                        EditImageUrl="../Images/edit.gif" ItemStyle-HorizontalAlign="Center">
                    </telerik:GridEditCommandColumn>
                    <telerik:GridTemplateColumn HeaderText="Delete" UniqueName="Delete" HeaderStyle-HorizontalAlign="Center" ItemStyle-Width="40px" ItemStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <asp:ImageButton runat="server" ID="imgdelete" OnClientClick="return confirm('Are you sure that you want to Delete?');"
                                ImageUrl="../Images/delete.gif" CommandName="Delete" CommandArgument="" />
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                 
                     
 
                    <telerik:GridTemplateColumn HeaderStyle-Width="180" UniqueName="Rate" HeaderText="Rate" ItemStyle-HorizontalAlign="Left"
                            HeaderStyle-HorizontalAlign="Center" FooterStyle-HorizontalAlign="Right">
                            <ItemTemplate>
                                <asp:RadioButton ID="rdbtnPerSqft" runat="server" Text="PerSqft" GroupName="Rate" Enabled="false" Checked='<%# bool.Parse(Eval("IsPerSqftRate").ToString()) %>' />
                                <asp:RadioButton ID="rdbtnFlat" runat="server" Text="Flat" GroupName="Rate" Enabled="false" Checked='<%# bool.Parse(Eval("IsFlatRate").ToString()) %>' />
                            </ItemTemplate>
                        <EditItemTemplate>
                             <asp:RadioButton ID="rdbtnPerSqftEdit" runat="server" Text="PerSqft" GroupName="Rate" Checked='<%# bool.Parse(Eval("IsPerSqftRate").ToString()) %>'   />
                                <asp:RadioButton ID="rdbtnFlatEdit" runat="server"  CommandName="Flatrate" Text="Flat" GroupName="Rate" Checked='<%# bool.Parse(Eval("IsFlatRate").ToString()) %>' />
                                <asp:TextBox ID="txtRateEdit" runat="server"  Width="55" CssClass="AlgRgh" Visible="true"  Text='<%# string.Format("{0:n}", Convert.ToDecimal(Eval("PerSqFtRate"))) %>'
                                    onkeypress="javascript:return Allownumbersonly(event);" BorderWidth="1px" ></asp:TextBox>
                        </EditItemTemplate>
                        <InsertItemTemplate>
                            <asp:RadioButton ID="rdbtnPerSqftinsert"  runat="server" Text="PerSqft" GroupName="Rate"    />
                                <asp:RadioButton ID="rdbtnFlatinsert" runat="server" Text="Flat" GroupName="Rate"   />
                                <asp:TextBox ID="txtRateinsert" runat="server"  Width="55"  CssClass="AlgRgh"
                                    onkeypress="javascript:return Allownumbersonly(event);" BorderWidth="1px" ></asp:TextBox>
                        </InsertItemTemplate>
                        </telerik:GridTemplateColumn>
 
                </Columns>
            </telerik:GridTableView>
        </DetailTables>
        <Columns>
            <telerik:GridTemplateColumn HeaderText="AccountId" UniqueName="TempAccountsId" Visible="false">
                <ItemTemplate>
                    <asp:Label ID="lblTempAccountsId" runat="server" Text='<%#Eval("TempAccountsId") %>'></asp:Label>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn HeaderText="Account Number" UniqueName="AccountNumber" ItemStyle-Width="120px" HeaderStyle-Width="120px" HeaderStyle-HorizontalAlign="left" ItemStyle-HorizontalAlign="left">
                <ItemTemplate>
                    <asp:Label ID="lblAccountNumber" runat="server" Text='<%#Eval("AccountNumber") %>'></asp:Label>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn HeaderText="Account Name" UniqueName="AccountName" ItemStyle-Width="140px" HeaderStyle-Width="140px" HeaderStyle-HorizontalAlign="left" ItemStyle-HorizontalAlign="left">
                <ItemTemplate>
                    <asp:Label ID="lblAccountName" runat="server" Text='<%#Eval("AccountName") %>'></asp:Label>
                </ItemTemplate>
                <FooterTemplate>
                    <asp:Label ID="lbltotalFooter" runat="server" Text="Total:"></asp:Label>
                </FooterTemplate>
            </telerik:GridTemplateColumn>
             
        </Columns>
    </MasterTableView>
    <ClientSettings AllowKeyboardNavigation="true" EnableRowHoverStyle="true">
        
    </ClientSettings>
</telerik:RadGrid>

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 30 Sep 2013, 06:21 AM
Hi,

Please try using the telerik RadButton with ButtonType to 'ToggleButton' and ToggleType to 'Radio', Then you can set CommandName to the RadioButton.

ASPX:
<EditItemTemplate>
    <telerik:RadButton ToggleType="Radio" ButtonType="ToggleButton" runat="server" Text="RadioButton1"
        CommandName="RadioButton1" >
    </telerik:RadButton>
      .  .   .

C#:
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
    if (e.CommandName == "RadioButton1")
    {
        GridEditableItem Edit = (GridEditableItem)e.Item;
        TextBox TextBox1 = (TextBox)Edit.FindControl("txtRateEdit");
        TextBox1.Text = "Hello";
    }
}

Thanks,
Princy.
0
courtney shoell
Top achievements
Rank 1
answered on 15 Oct 2013, 09:49 AM
Thank you. telerik RadButton solved my problem.
Tags
Grid
Asked by
courtney shoell
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
courtney shoell
Top achievements
Rank 1
Share this question
or