@using Syncfusion.Blazor.Buttons
@using System.ComponentModel.DataAnnotations
<EditForm Model="@Annotate" OnValidSubmit="onValid">
<DataAnnotationsValidator></DataAnnotationsValidator>
<div class="form-group">
<SfRadioButton Label="Male" Name="Gender" Value="male" Checked="@(Annotate.Gender == "male")" @onchange="@(() => { Annotate.Gender = "male"; })"></SfRadioButton>
<SfRadioButton Label="Female" Name="Gender" Value="female" Checked="@(Annotate.Gender == "female")" @onchange="@(() => { Annotate.Gender = "female"; })"></SfRadioButton>
<ValidationMessage For="@(() => Annotate.Gender)" />
</div>
<SfButton HtmlAttributes="@Submit" Content="Submit" IsPrimary="true"></SfButton>
</EditForm>
@code {
public Annotation Annotate = new Annotation();
public class Annotation
{
[Required]
public string Gender { get; set; }
}
public Dictionary<string, object> Submit = new Dictionary<string, object>()
{
{ "type", "submit"}
};
public void onValid()
{
}
} |
Hi Saranya ,
I have a column sfradiobutton inside the Sfgrid seems the radiobutton two way binding issure.
I link the feedback portal, access deny.
Hi Jacky,
We have reviewed the reported query, and in order to resolve the two binding issues, you need to set a unique name for each radio button in every grid column. Please refer to the code snippet and sample below.
<SfGrid DataSource="@Orders" AllowPaging="true"> <GridPageSettings PageSize="5"></GridPageSettings> <GridColumns> <GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" TextAlign="TextAlign.Right" Width="120"></GridColumn> <GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" Width="150"></GridColumn> <GridColumn Field=@nameof(Order.Verified) HeaderText="Verified" Width="200"> <Template Context="RadioContext"> @{ var employee = (RadioContext as Order); <div class="col-md-6"> <SfRadioButton Label="first" Name="@employee.OrderID.ToString()" @ref="Radio[employee.OrderID]" Value="true" TChecked="bool" ></SfRadioButton> <SfRadioButton Label="second" Name="@employee.OrderID.ToString()" @ref="Radio[employee.OrderID]" Value="true" TChecked="bool"></SfRadioButton> <SfRadioButton Label="third" Name="@employee.OrderID.ToString()" @ref="Radio[employee.OrderID]" Value="true" TChecked="bool"></SfRadioButton> <SfRadioButton Label="fourth" Name="@employee.OrderID.ToString()" @ref="Radio[employee.OrderID]" Value="true" TChecked="bool"></SfRadioButton> </div> } </Template> </GridColumn> <GridColumn Field=@nameof(Order.OrderDate) HeaderText="Order Date" Format="d" Type="ColumnType.DateOnly" TextAlign="TextAlign.Right" Width="130"></GridColumn> <GridColumn Field=@nameof(Order.OrderTime) HeaderText="Order Time" Type="ColumnType.TimeOnly" TextAlign="TextAlign.Right" Width="130"></GridColumn> <GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" Width="120"></GridColumn> </GridColumns> </SfGrid> |
If we misunderstood your query, could you please provide more details with the issue's replicable sample or replicate the issue in our sample with replication steps and a video demonstration? Based on that, we will check and provide you with a better solution quickly.
Please let us know if you need any further assistance on this.
Regards,
KeerthiKaran K V