We have a grid with editor templates for a few types that are tied to a dropdownlist that is tied to a datasource. When user clicks new/add they get an empty form (we are using popup) but we would like the drowdowns to be preselected with the first values in the datasource. How do we do this? Is there some SelectedIndex property or similar available?
We are currently doing something like this but it does not seem to nice even though it works.
Also, what is the best way to differentiate between add and update in the EditorTemplate, ie how do we know what is what?
<EditorTemplate>
@{
EditingCorporateCustomer = context as CorporateCustomerDto;
if (EditingCorporateCustomer.CompanyTypeId == 0)
{
EditingCorporateCustomer.CompanyTypeId = CompanyTypes[0].Id;
}
<TelerikDropDownList Data="@CompanyTypes" @bind-Value="@EditingCorporateCustomer.CompanyTypeId"
Width="95%"
TextField="Name"
ValueField="Id">
</TelerikDropDownList>
}
</EditorTemplate>