jQuery UI Widgets › Forums › Lists › DropDownList › Binding Dropdownlist data from Database
Tagged: angular dropdownlist, asp, asp.net, database, DropDownList, jQuery DropDownList, jqxDropDownList, sql
This topic contains 1 reply, has 2 voices, and was last updated by Dimitar 9 years, 2 months ago.
-
Author
-
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
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,
DimitarjQWidgets team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.