我正在尝试使用jqGrid将字符串数组发送到Web服务。这是我的示例Web服务。请注意,它接受可变数量的参数并返回XML。我收到500内部服务器错误,我正在使用jqGrid 4.2和.NET3.5。
[WebMethod]
public XmlDocument ListTest(List<string> arr)
{
string strSQL;
strSQL = "SELECT testColumn, rowid FROM testTable WHERE isTest=true ";
if (arr[0] != "")
strSQL += " AND testOption0 >= \"" + arr[0] + "\"";
if (arr[1] != "")
strSQL += " AND testOption1 <= \"" + arr[1] + "\"";
if (arr[2] != "")
strSQL += " AND testOption2 = \"" + arr[2] + "\"";
if (arr[3] != "")
strSQL += " AND testOption3 = \"" + arr[3] + "\"";
if (arr[4] != "")
strSQL += " AND testOption4 = \"" + arr[4] + "\"";
//execute query
DataSet myDataSet = new DataSet();
OdbcConnection Conn = new OdbcConnection(strConnString);
OdbcDataAdapter da = new OdbcDataAdapter(strSQL, Conn);
da.Fill(myDataSet, "QuickSearchItem");
//convert data to xml and return
XmlDocument xmldoc = new XmlDocument();
string rawxml = "";
rawxml = rawxml + myDataSet.GetXml();
xmldoc.LoadXml(rawxml);
return xmldoc;
}
这是我的jqGrid电话:
function bindGridDataQS(findAll, isMotionCheck){
var myCars = new Array();
myCars[0] = "";
myCars[1] = "test1";
myCars[2] = "";
myCars[3] = "";
myCars[4] = "test4";
$("#myGrid").jqGrid({
url:'WebService.asmx/ListTest',
postData: JSON.stringify({arr: myCars}),
datatype: 'xml',
colNames:["make","model", "year"],
colModel:[
{name:"make",index:"make", width:260, align:"center", xmlmap:"make"},
{name:"model",index:"model", width:210, align:"center", xmlmap:"model"},
{name:"year",index:"year", width:180, align:"center",xmlmap:"year", sorttype:"float"}
],
viewrecords: true,
loadonce: false,
xmlReader: {
root : "NewDataSet",
row: "QuickSearchItem",
repeatitems: false,
id: "rowid"
},
//pager:'#QSGridNav',
onSelectRow: function(id){ playVideo(id);},
caption: "Event Video List"
});
}