jQuery UI Widgets Forums Lists DropDownList Binding Dropdownlist data from Database

This topic contains 1 reply, has 2 voices, and was last updated by  Dimitar 7 years ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • Binding Dropdownlist data from Database #75854

    divya
    Participant

    Hi,
    I have used below code to bind data from database to dropdownlist(Using asp.net). The code is returning values but is not getting bounded to Dropdownlist.

    <script type=”text/javascript”>
    $(document).ready(function () {
    $(“#loadButton”).jqxButton();
    source = {
    datatype: “xml”,
    datafields: [
    { name: ‘id’ },
    { name: ‘name’ }
    ],
    async: false,
    record: ‘Table’,
    url: ‘oemPatches.aspx/BindOEM’,
    };
    console.log(source);
    var dataAdapter = new $.jqx.dataAdapter(source,
    { contentType: ‘application/json; charset=utf-8’ });
    $(“#ddlOEM”).jqxDropDownList(
    {
    source: dataAdapter,
    theme: ‘classic’,
    width: 200,
    height: 25,
    selectedIndex: 1,
    displayMember: ‘NAME’,
    valueMember: ‘ID’
    });
    });
    </script>

    <div id=’ddlOEM’>
    </div>

    Aspx.cs file
    [WebMethod]
    [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Xml)]
    public static string BindOEM()
    {
    SupportUI.classes.data.UtilityDAL dal = new SupportUI.classes.data.UtilityDAL();
    string query = “SELECT id, name FROM oems ORDER BY oem_name”;
    DataSet dsResult = dal.executeQuery(query);
    //// return the Customers table as XML.
    System.IO.StringWriter writer = new System.IO.StringWriter();
    dsResult.Tables[0].WriteXml(writer, XmlWriteMode.WriteSchema, false);
    return writer.ToString();
    //return JSON.FromDataTable(dsResult.Tables[0]);
    }

    When seen in chrome browser dataadapter source is empty

    Binding Dropdownlist data from Database #75878

    Dimitar
    Participant

    Hi divya,

    Please take a look at our ASP .NET MVC demos and especially Bind DropDownList to SQL Database, which shows how to populate this widget from a database.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.