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

Auto Populate DropDownList on page_load

1 Answer 94 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 04 Jan 2019, 05:20 PM

I have an array of items of possible CSV fields that when the page load i need it to auto populate with the correct field name of the CSV, 

<div id="divRadGridCsvImport_Wrapper" class="RadGridWrapper">
                    <telerik:RadGrid EnableLinqExpressions="False" ID="radgridCsvMapping" runat="server" AutoGenerateColumns="false" AllowPaging="False" AllowSorting="False" GridLines="None" Width="500">
                        <ClientSettings EnableRowHoverStyle="true"></ClientSettings>


                        <MasterTableView>
                            <Columns>
                                <telerik:GridTemplateColumn HeaderText="CSV Field">
                                    <ItemTemplate>
                                        <asp:Label ID="CSVfield" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.CSVfield")%>'></asp:Label>
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridTemplateColumn HeaderText="Sample Data">
                                    <ItemTemplate>
                                        <asp:Label ID="SampleData" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.CSVfield")%>'></asp:Label>
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridTemplateColumn HeaderText="System Field">
                                    <ItemTemplate>
                                        <asp:DropDownList CssClass="inputfields" ID="dropDownColumnName" onchange="FieldMappingsOnChange(this)" runat="server" />
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
                                
                            
                            </Columns>
                            <NoRecordsTemplate>
                                <div>
                                    <asp:Literal ID="litNoRecords" runat="server" Text="No Records" />
                                </div>
                            </NoRecordsTemplate>
                        </MasterTableView>
                    </telerik:RadGrid>
                </div>

See in the image loaded, i'm trying to make it easier for users so if a match to the field with our field names is closer i.e. same names or close to as possible, it will load these when the page loads. then the user can change and fill in the ones that couldn't be automatically populated. I think Load On Demand may work, but before i try this, i'd like to know if it can be done or what others are doing.

 

Thanks

1 Answer, 1 is accepted

Sort by
0
Vessy
Telerik team
answered on 09 Jan 2019, 01:44 PM
Hi Kevin,

You can set the SelectedValue  use RadDropDownlist depending on the current row data in a similar way :
<telerik:RadDropDownList RenderMode="Lightweight" runat="server" ID="RadDropDownList1"  DataTextField="CategoryName"
    DataValueField="CategoryID" DataSourceID="CategoriesDataSource" SelectedValue='<%#Bind("CategoryID") %>'>
</telerik:RadDropDownList>

Such approach is demonstrated in the following demo (in the edit template of the Category column:
https://demos.telerik.com/aspnet-ajax/dropdownlist/examples/applicationscenarios/dropdownlistingird/defaultcs.aspx

Regards,
Vessy
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
DropDownList
Asked by
Kevin
Top achievements
Rank 1
Answers by
Vessy
Telerik team
Share this question
or