Auto Populate DropDownList on page_load

2 posts, 0 answers
  1. Kevin
    Kevin avatar
    3 posts
    Member since:
    Jan 2019

    Posted 04 Jan 2019 Link to this post

    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>

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

    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.



  2. Vessy
    Vessy avatar
    2367 posts

    Posted 09 Jan 2019 Link to this post

    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") %>'>

    Such approach is demonstrated in the following demo (in the edit template of the Category column:

    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.
Back to Top