我想在android中显示一个自定义列表视图。
这是我使用产品位置过滤产品的网络服务。
public class Record
{
public string city { get; set; }
public string description { get; set; }
public string mobile { get; set; }
}
[WebMethod]
public string filter(int flt)
{
string cmdStr = "select * from add_product where prod_pos ='" + flt.ToString() + "'";
SqlDataReader rd = con.Getdata(cmdStr);
List<Record> records = new List<Record>();
while (rd.Read())
{
records.Add(new Record()
{
city = rd.GetString(1).ToString(),
description = rd.GetString(3).ToString(),
mobile = rd.GetString(5).ToString(),
});
}
var oSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();
string sJSON = oSerializer.Serialize(records);
rd.Close();
return "data"+sJSON;
}
当我们通过在服务器上发布它在服务器上测试它时 Web 服务的输出.. 当我们通过 int flt="5"
<string>
data[
{"city":"Aurangabad","description":"desktops dell prize 3000","mobile":"9850888129"},
{"city":"Pune","description":"gg","mobile":"8600525858"}
]
</string>
以下是我的 add_product 表条目....
[id_prod data type int] // auto increment... primary key
[city data type varchar(50)]
[category data type varchar(50)]
[description data type varchar(MAx)]
[prod_pos data type int]
[mobile datatype varchar(20)]
[image datatype text]
提前致谢...