API をヒットし、返された解析済みデータをList
. 現在、データを に表示していますListView
。で同じリストを表示できませんGridView
。誰かがそれを行う方法を教えてもらえますか?
これは私の aspx.cs コードです:
protected void Page_Load(object sender, EventArgs e)
{
ComodityList obj_comodity_in = (ComodityList)Session["comodity_list"];
Label1.Text = obj_comodity_in.status_code;
Label2.Text = obj_comodity_in.count.ToString();
//ComodityList obj_comodity_in = (ComodityList)Session["comodity_list"];
List<String> commodity_names = null;
getComodityNames(out commodity_names, obj_comodity_in);
ListView1.DataSource = commodity_names;
ListView1.DataBind();
}
private void getComodityNames(out List<String> commodity_names, ComodityList cl)
{
commodity_names = new List<string>();
foreach (Commodity c in cl.data)
{
commodity_names.Add(c.commodity);
commodity_names.Add(c.state);
commodity_names.Add(c.market);
commodity_names.Add(c.Maximum_Price.ToString());
commodity_names.Add(c.Minimum_Price.ToString());
commodity_names.Add(c.Modal_Price.ToString());
commodity_names.Add(c.origin);
commodity_names.Add(c.unit);
commodity_names.Add(c.variety);
}
}