how to pass parameter from url to behind code
Hi..
I have a function behind code that generate xml from database query..
I use jqxgrid to display a table.. and the data displayed was chosen by user from a dropdownlist..
I have problem on passsing the parameter..
Appreciate if someone can advice me.. THanks..
- $(document).ready(function () {
- var e = document.getElementById("MainContent_ddlType");
- var selectedT = e.options[e.selectedIndex].text;
- ;
-
- source = {
- datatype: "xml",
- datafields: [
- { name: 'ID' },
- { name: 'TYPE' },
- { name: 'STATUS' },
- { name: 'ROOT_CAUSE' },
- { name: 'CREATION_DATE' }
- ],
- type: "POST",
- url: 'Index.aspx/GetDetails',
- data: JSON.stringify({selectedType: selectedT}),
- async: false,
- record: 'Table',
- };
- var dataAdapter = new $.jqx.dataAdapter(source,
- { contentType: 'application/json; charset=utf-8' }
- );
- //alert(dataAdapter.);
-
- $("#jqxgrid").jqxGrid(
- {
- width: 600,
- height: 450,
- source: dataAdapter,
- theme: 'classic',
- sortable: true,
- pageable: true,
- columns: [
- { text: 'ID', datafield: 'ID', width: 250 },
- { text: 'Type', datafield: 'TYPE', width: 150 },
- { text: 'Status', datafield: 'STATUS', width: 150 },
- { text: 'Root Cause', datafield: 'ROOT_CAUSE', width: 180, cellsalign: 'right' },
- { text: 'Creation Date', datafield: 'CREATION_DATE', width: 100, cellsalign: 'right', cellsformat: 'c2' }
- ]
- });
- });
-
code behind:
- [WebMethod]
- [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Xml)]
- public static string GetExceptionDetails(string selectedType)
- {
- string selectString = "SELECT * FROM table_details where type= '" + selectedType + "'";
- oledb.OleDbCommand cmd = new oledb.OleDbCommand(selectString);
-
- //populate the DataSet
- DataSet data = GetData(cmd);
-
- //return the tables as XML
- System.IO.StringWriter writer = new System.IO.StringWriter();
- data.Tables[0].WriteXml(writer, XmlWriteMode.WriteSchema, false);
- return writer.ToString();
- }
-