如何在asp.net C#中使用jquery绑定ul li标签

时间:2017-01-05 11:40:52

标签: javascript asp.net sql-server json

我写了这段代码,但没有得到我想要的结果。请帮帮我

javascript代码

$.ajax({
  type: "POST",
  url: "userControls/Wsc_comn.asmx/BindCategory",
  data: "{}",
  dataType: "json",
  contentType: "application/json; charset=utf-8",
  async: true,
  success: OnSuccess,
  error: OnError
});

function OnSuccess(data) {

  $.each(data, function(key, value) {
    $("#tablet").append("<li><a rel='external' href='" + this.attachment_url + "'>" + value.Product_name + "</li>");
  });
}

function OnError(data) {

}

c#c​​ode

 [WebMethod]
    [ScriptMethod(UseHttpGet = false, ResponseFormat = ResponseFormat.Json)]

    public string BindCategory()
    { 



      string qry = "select *from products where Product_type='TABLETS'";
      DataTable dt = dllmain.ExecuteselectQry_returns_datatable(qry);
      foreach (DataRow row in dt.Rows)
      {
        string urls = row["attachment_url"].ToString();
        string catname = row["Product_name"].ToString();



      }
      return dllgetinfo.getdatatabletojson(dt);


   }

0 个答案:

没有答案