2
Answers

How to Bind ul li tag using jquery in asp.net C#

rajeev kumar

rajeev kumar

7y
848
1

have written this code but not getting result as i want. data is not showing in ul li but when running webservice getting all data as it is in db.   please help me

javascript code is

$.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# code
 
 
[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);
}
 
 
 
 
 
 
Answers (2)