Search code examples
htmlasp.net-mvcteleriktelerik-mvc

Updating dropdown lists to Telerik


I have a form with few drop-down lists, something like this:

<table>
            <tr>
                <th>
                    Student Number
                </th>
                <td>
                    <input type="text" id="StudentNumber" />
                </td>
            </tr>
            <tr>
                <th>
                    Student Type
                </th>
                <td>
                    <select id="StudentType">
                        <option value="Select">Select</option>
                        <option value="Freshman">Freshman</option>
                        <option value="Sophomore">Sophomore</option>
                        <option value="Junior">Junior</option>
                        <option value="Senior">Senior</option>
                    </select>
                </td>
            </tr>
            <tr>
                <th>
                    Status
                </th>
                <td>
                    <select id="Status">
                        <option value="Select">Select</option>
                        <option value="Enrolled">Enrolled</option>
                        <option value="Dropped">Dropped</option>
                        <option value="Probation">Probation</option>
                        <option value="Suspended">Suspended</option>
                    </select>
                </td>
            </tr>
</table>

I want to convert the HTML dropdown-lists to telerik dropdown-lists. What entails in converting a control to Telerik? This is my first time with Telerik. Any examples would be very helpful

Thanks in advance


Solution

  • If you just want to use static data like you have in your question, you can do this:

    @(Html.Telerik().DropDownList()
      .Name("StudentType")
      .Items(items =>
        {
          items.Add().Text("Select").Value("Select");
          items.Add().Text("Freshman").Value("Freshman");
          items.Add().Text("Sophmore").Value("Sophmore");
          items.Add().Text("Junior").Value("Junior");
          items.Add().Text("Senior").Value("Senior");
        })
    )
    

    For a demo using dynamic data, see Telerik's combobox/dropdown demo.