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

radbutton as radio button does not work in radgrid editform template

3 Answers 55 Views
Button
This is a migrated thread and some comments may be shown as answers.
Jay
Top achievements
Rank 1
Jay asked on 02 Sep 2015, 05:13 PM

Radbutton as a radio button does not work (you cannot toggle a set of radio buttons within a group) when placed in an editform template in radgrid.

They work outside of the radgrid but I need them to work in the radgrid

Is there something special that needs to be done when inside a template editform in radgrid.

 

3 Answers, 1 is accepted

Sort by
0
Danail Vasilev
Telerik team
answered on 07 Sep 2015, 06:43 AM
Hi Jay,

Could you please try to reproduce the issue with the code below and then tell us what changes you have made, so that I can proceed further with the investigation?

ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource" AutoGenerateEditColumn="true">
    <MasterTableView AutoGenerateColumns="false">
        <Columns>
            <telerik:GridTemplateColumn HeaderText="ID">
                <ItemTemplate>
                    <asp:Label ID="Label1" Text='<%# Eval("SellQuantity")%>' runat="server" />
                </ItemTemplate>
                <EditItemTemplate>
                    <telerik:RadButton ID="RadButton1" runat="server" ButtonType="ToggleButton" ToggleType="Radio" Checked='<%# Eval("IsCheckedFirst")%>' GroupName="group1">
                        <ToggleStates>
                            <telerik:RadButtonToggleState Text="Checked first" Selected="true" />
                            <telerik:RadButtonToggleState Text="UnChecked first" />
                        </ToggleStates>
                    </telerik:RadButton>
                    <telerik:RadButton ID="RadButton2" runat="server" ButtonType="ToggleButton" ToggleType="Radio" GroupName="group1" Checked='<%# !(bool)Eval("IsCheckedFirst")%>'>
                        <ToggleStates>
                            <telerik:RadButtonToggleState Text="Checked second" />
                            <telerik:RadButtonToggleState Text="UnChecked second" />
                        </ToggleStates>
                    </telerik:RadButton>
                </EditItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridBoundColumn DataField="SellQuantity" HeaderText="Sell Quantity"></telerik:GridBoundColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

C#:
protected DataTable GetData()
{
    DataTable dt = new DataTable();
 
    dt.Columns.Add("ID", typeof(int));
    dt.Columns.Add("isCheckedFirst", typeof(bool));
    dt.Columns.Add("SellQuantity", typeof(int));
    dt.Columns.Add("SellDate", typeof(DateTime));
 
    dt.Rows.Add(1, true, 2, new DateTime(2011, 06, 12));
    dt.Rows.Add(2, false, 5, new DateTime(2011, 12, 12));
    dt.Rows.Add(3, false, 6, new DateTime(2012, 06, 17));
    dt.Rows.Add(4, true, 4, new DateTime(2012, 09, 18));
    dt.Rows.Add(5, true, 7, new DateTime(2013, 03, 18));
 
    return dt;
}
 
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
    RadGrid1.DataSource = GetData();
}



Regards,
Danail Vasilev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Jay
Top achievements
Rank 1
answered on 08 Sep 2015, 07:36 PM

The problem is with getting the telerik radiobutton to work in the EditForm template.

Your example works in the editItem template ( I verified this) but unfortunately not in the EditForm template of RadGrid.

 

<telerik:RadGrid ID="RadGrid1" runat="server" ...>

<MasterTableView AutoGenerateColumns="False" ... >

<EditFormSettings EditFormType="Template">

 ...

</EditFormSettings>

</MasterTableView>

</telerik:RadGrid>

 

0
Danail Vasilev
Telerik team
answered on 11 Sep 2015, 07:14 AM
Hi Jay,

I have tried utilizing the edit form template with the radiobutton but once again the scenario works properly on my side:

ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource" AutoGenerateEditColumn="true">
    <MasterTableView AutoGenerateColumns="false">
        <EditFormSettings EditFormType="Template">
            <FormTemplate>
                <telerik:RadButton ID="RadButton1" runat="server" ButtonType="ToggleButton" ToggleType="Radio" Checked='<%# Eval("IsCheckedFirst")%>' GroupName="group1">
                    <ToggleStates>
                        <telerik:RadButtonToggleState Text="Checked first" Selected="true" />
                        <telerik:RadButtonToggleState Text="UnChecked first" />
                    </ToggleStates>
                </telerik:RadButton>
                <telerik:RadButton ID="RadButton2" runat="server" ButtonType="ToggleButton" ToggleType="Radio" GroupName="group1" Checked='<%# !(bool)Eval("IsCheckedFirst")%>'>
                    <ToggleStates>
                        <telerik:RadButtonToggleState Text="Checked second" />
                        <telerik:RadButtonToggleState Text="UnChecked second" />
                    </ToggleStates>
                </telerik:RadButton>
            </FormTemplate>
        </EditFormSettings>
        <Columns>
            <telerik:GridBoundColumn DataField="ID" HeaderText="ID"></telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="SellQuantity" HeaderText="Sell Quantity"></telerik:GridBoundColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

I would suggest that you provide us with the exact runnable code that reproduces the issue, so that we can investigate it further and provide a solution if possible.

Regards,
Danail Vasilev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Button
Asked by
Jay
Top achievements
Rank 1
Answers by
Danail Vasilev
Telerik team
Jay
Top achievements
Rank 1
Share this question
or