日期:2014-05-17 浏览次数:20590 次
private string OutputPrice()
{
string sql = "select * from YuyaoPrice where ClassId=1 and SmallId=435";
DataTable dt = DBclass.ExecSel(sql);
for (int i = 0; i < dt.Rows.Count; i++)
{
string a = dt.Rows[i]["NewPrice"].ToString();
string b = ",";
string c = a + b;
Price = c.ToString();
}
return Price;
}
public string Price = string.Empty;
protected void Page_Load(object sender, EventArgs e)
{
Price = OutputPrice();
Response.Write(Price.ToString());//读出来只有:15900,
}
private List<string> OutputPrice()
{
string sql = "select * from YuyaoPrice where ClassId=1 and SmallId=435";
DataTable dt = DBclass.ExecSel(sql);
for (int i = 0; i < dt.Rows.Count; i++)
{
string a = dt.Rows[i]["NewPrice"].ToString();
string b = ",";
string c = a + b;
Prices.Add(c.ToString());
}
return Prices;
}
public List<string> Prices = new List<string>();
protected void Page_Load(object sender, EventArgs e)
{
Prices = OutputPrice();
foreach (string Price in Prices)
{
Response.Write(Price.ToString());//读出来只有:15900,
}
}
------解决方案--------------------
你这样是循环赋值,并没有追加,肯定最多只有一个了。
------解决方案--------------------