Hai friends i am using jqwidgets plugin to populate table data.
my requirement is to display data on table by the combobox selection
i am using asp.net
my problem is how to pass parameter to function “GetCustomersfn(string cusID)”
if i use parameter less function ie GetCustomersfn() i get the expected result.
please help..
Function given below
[WebMethod]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Xml)]
public string GetCustomersfn(string cusID)
{
string query = "SELECT * FROM Customers WHERE CustomerID LIKE @CustomerID";
string tablename = "Customers";
SqlCommand cmd = new SqlCommand(query);
cmd.Parameters.AddWithValue("CustomerID", "%" + cusID.Substring(0, 1) + "%");
DataSet data = GetData(cmd, tablename);
System.IO.StringWriter writer = new System.IO.StringWriter();
data.Tables[0].WriteXml(writer, XmlWriteMode.WriteSchema, false);
return writer.ToString();
}
script file is given below
<script type="text/javascript">
$(document).ready(function () {
$('#dlcustomers').change(function () {
var cid = $.trim($("[id*=dlcustomers]").val());
alert(cid);
source = {
datatype: "xml",
datafields: [
{ name: 'CompanyName' },
{ name: 'ContactName' },
{ name: 'ContactTitle' },
{ name: 'City' },
{ name: 'Country' },
{ name: 'Address' }
],
async: false,
record: 'Customers',
url: 'DataWebService.asmx/GetCustomersfn',
data: { CusID: 'A'}
};
var dataAdapter = new $.jqx.dataAdapter(source,
{ contentType: 'application/json; charset=utf-8' }
);
$("#dataTable").jqxDataTable(
{
width: 850,
height: 400,
source: dataAdapter,
pagerButtonsCount: 10,
pageable: true,
columnsresize: true,
altRows: true,
filterable: true,
sortable: true,
filtermode: 'advanced',
columns: [
{ text: 'Company Name', dataField: 'CompanyName', width: 250 },
{ text: 'Contact Name', dataField: 'ContactName', width: 150 },
{ text: 'Contact Title', dataField: 'ContactTitle', width: 180 },
{ text: 'Address', dataField: 'Address', width: 180 },
{ text: 'City', dataField: 'City', width: 80 },
{ text: 'Country', dataField: 'Country', width: 100 }
]
});
});
});
</script>
please help.. thanks in advance