C#后台数组传到前台的javascript
public class info {
public int Cai_No = 0;
public string Cai_Name = "";
public int Price = 0;
}
public info[] myinfo=new info[50];
public void SetInfo()
{
for(int i=0;i<cai_count;++i)
{
myinfo[i] = new info();
myinfo[i].Cai_No = int.Parse(cai_info[0, i]);
myinfo[i].Cai_Name = cai_info[1, i];
myinfo[i].Price = int.Parse(cai_info[4, i]);
}
}
for (var i = 0; i < cai_count ; i++) {
cai[i] = new Array();
document.cookie = "Count="+i;
cai[i][0] = "<%=myinfo[i].Cai_No%>";
cai[i][1] = "<%=myinfo[i].Cai_Name%>";
cai[i][2] = "<%=myinfo[i].Price%>";
}
下边传进来不能用i这类变量,该怎么办?
------解决方案--------------------转成json字符再给js不好吗?
------解决方案--------------------
去网上找数组转JSON的类,在通过 输出respose到前台,解析JSON.
------解决方案-------------------- 后台代码
Dictionary<int, object> installlist = installBll.GetInstallInfo(company.CompanyID, null);
for (int i = 1; i < 13; i++){