Is it possible to add CommandName to radiobotton?

3 posts, 0 answers
  1. courtney shoell
    courtney shoell avatar
    4 posts
    Member since:
    Nov 2009

    Posted 26 Sep 2013 Link to this post

    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. Princy
    Princy avatar
    16662 posts
    Member since:
    Mar 2007

    Posted 30 Sep 2013 Link to this post

    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.

  3. courtney shoell
    courtney shoell avatar
    4 posts
    Member since:
    Nov 2009

    Posted 15 Oct 2013 Link to this post

    Thank you. telerik RadButton solved my problem.

Back to Top