更新时间:2022-12-07 19:03:01
('#ddltitle:selected')。text()+| +
(#<%= txtfn.ClientID%>)。val()+| +
(#<%= txtmn.ClientID%>)。val()+| +
Hi guys,
i have asp.net website,
where i'm using jqxgrid to bind data from a html table,
I have one add button in this table and i'm calling this ADD2Grid().
Code:
<script type="text/javascript"> function ADD2Grid() { //Getting the source data with ajax GET request var tt = $('#ddltitle :selected').text() + "|" + $("#<%=txtfn.ClientID %>").val() + "|" + $("#<%=txtmn.ClientID %>").val() + "|" + $("#<%=txtln.ClientID %>").val(); //alert(tt); source = { datatype: "xml", datafields: [ { name: 'Title', type: 'string' }, { name: 'First Name', type: 'string' }, { name: 'Middle Name', type: 'string' }, { name: 'Last Name', type: 'string' } ], async: false, record: 'Table', url: 'Default.aspx/GetCustomers', data: '{ data1:' + tt + '}',//Error success: alert(data.d) }; var dataAdapter = new $.jqx.dataAdapter(source, { contentType: 'application/json; charset=utf-8'} ); $("#jqxgrid").jqxGrid({ source: dataAdapter, theme: 'classic', columns: [ { text: 'Title', dataField: 'Title', width: 50 }, { text: 'First Name', dataField: 'First Name', width: 250 }, { text: 'Middle Name', dataField: 'Middle Name', width: 250 }, { text: 'Last Name', dataField: 'Last Name', width: 250 } ] }); }; </script>
Default.aspx
protected static DataSet GetData(string data) { DataSet ds = new DataSet(); DataTable dt = new DataTable(); if (dt == null) { dt.Columns.Add("Title", typeof(string)); dt.Columns.Add("First Name", typeof(string)); dt.Columns.Add("Middle Name", typeof(string)); dt.Columns.Add("Last Name", typeof(string)); } else { dt = HttpContext.Current.Session["MyTable"] as DataTable; } string[] split = data.Split('|'); DataRow dr = dt.NewRow(); dr["Title"] = split[0]; dr["First Name"] = split[1]; dr["Middle Name"] = split[2]; dr["Last Name"] = split[3]; dt.Rows.Add(dr); HttpContext.Current.Session["MyTable"] = dt; ds.Tables.Add(dt); return ds; } [WebMethod] [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Xml)] public static string GetCustomers(string data1) { // Populate the DataSet. DataSet data = GetData(data1); // return the Customers table as XML. StringWriter writer = new StringWriter(); data.Tables[0].WriteXml(writer, XmlWriteMode.WriteSchema, false); return writer.ToString(); }
Can any one please help me.
Thanks
('#ddltitle :selected').text() + "|" +
("#<%=txtfn.ClientID %>").val() + "|" +
("#<%=txtmn.ClientID %>").val() + "|" +