Drop Down List Bind value not update with object field value.

Hello,


Right Now I am using sync-fusion grid to bind by object list TestList. In that For field ObjectiveValue  I am using one drop down with ObjectivityType List. But when I am select the value I can not able get the value on Update event on grid. So what's is the way that I can able to get the value for ObjectiveValue  from the drop down on Update or Save event when some-one change the value for the Test Object dropdown ? Thanks

 <SfGrid @ref="DefaultGrid" DataSource="@TestList" AllowResizing="true" AllowSorting="true" AllowMultiSorting="true" GridLines="GridLine.Both"
                AllowTextWrap="true" AllowFiltering="true" AllowPaging="false" Height="530" AllowExcelExport="false" AllowReordering="false" AllowGrouping="true" ShowColumnChooser="true"
                Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update","ColumnChooser"  })" ColumnMenuItems="MenuItems" Width="100%">
           
  <GridColumn Field=@nameof(Test.ObjectiveValue) HeaderText="A/ B" Width="200" EditType="EditType.DropDownEdit">
                    <EditTemplate>
                        <SfDropDownList ID="DrpTest" Placeholder="Select Value" TValue="string" TItem="DrpTest" DataSource="@drptestList" >
                            <DropDownListEvents TValue="string"></DropDownListEvents>
                            <DropDownListFieldSettings Text="Text" Value="Text"></DropDownListFieldSettings>
                        </SfDropDownList>
                    </EditTemplate>
                </GridColumn>

 </SfGrid>

My Class and data List which I am binding with dropdown :-

public class ObjectivityType
    {
        public string ID { get; set; }
        public string Text { get; set; }
    }
 public List<DrpTest> drptestList= new List<DrpTest>()
    {
        new DrpTest(){ ID= "1", Text= "Objective" },
        new DrpTest(){ ID= "2", Text= "Subjective" },
    };

Public Class Test
{
  public string ObjectiveValue { get; set; }
}

1 Reply 1 reply marked as answer

RN Rahul Narayanasamy Syncfusion Team October 28, 2020 02:18 PM UTC

Hi Karan, 

Greetings from Syncfusion. 

Query: Drop Down List Bind value not update with object field value.  

We have validated your query and you are having problem with updating the dropdown value which was rendered in EditTemplate. We suggest you to define the ID property to dropdown list and define @bind-Value to dropdown list as like below. Find the below code snippets and sample for your reference. 

 
<SfGrid AllowPaging="true" DataSource="@GridData" ShowColumnChooser="true" Toolbar="@(new List<string>() { "Add","Edit","Delete","Update","Cancel" })"> 
    <GridEditSettings AllowEditing="true" AllowDeleting="true" AllowAdding="true" Mode="@EditMode.Normal"></GridEditSettings> 
    <GridColumns> 
        <GridColumn Field=@nameof(Orders.OrderID) HeaderText="Order ID" IsPrimaryKey="true" TextAlign="@TextAlign.Center" Width="140"></GridColumn> 
        . . . 
        <GridColumn Field=@nameof(Orders.ShipCountry) HeaderText="Ship Country" EditType="EditType.DropDownEdit" Width="150"> 
            <EditTemplate> 
                <SfDropDownList ID="ShipCountry" Placeholder="Select a Country" TItem="string" TValue="string" @bind-Value="@((context as Orders).ShipCountry)" DataSource="@Countries"> 
                    <DropDownListFieldSettings Text="ShipCountry" Value="ShipCountry"></DropDownListFieldSettings> 
                </SfDropDownList> 
            </EditTemplate> 
        </GridColumn> 
    </GridColumns> 
</SfGrid> 


Please let us know if you if you have any concerns. 

Regards, 
Rahul 


Marked as answer
Loader.
Up arrow icon