[求助]往DataGrid插入数据的问题
double Sje=0.00; for(int i=0;i<DataGrid1.Items.Count;i++)
{
string Sstr="select distinct(SePaID),sum(SeFaMo)as SeFaMo from SePactInfo group by SePaID"; //把同一编号的费用相加
SqlDataReader Ssdr=odb.sdrOpen(Sstr);
while(Ssdr.Read())
{
//DataGrid里的编号等于SePaID
if(Ssdr.GetString(0)==DataGrid1.Items[i].Cells[1].Text)
{
Sje=Sje+Convert.ToDouble(Ssdr.GetString(1));
DataGrid1.Items[i].Cells[5].Text=Convert.ToString(Sje);
}
else
{
Response.Write("<script>alert('发生错误!')</script>");
}
}
Ssdr.Close();
}
foreach(DataGridItem dgi in DataGrid1.Controls[0].Controls)
{
if(dgi.ItemType == ListItemType.Footer)
{
dgi.Cells[5].Text = string.Format("{0:0.00}",Sje);
}
}
Sje=Sje+Convert.ToDouble(Ssdr.GetString(1));
这句错误,指定的转换无效。
[此贴子已经被作者于2007-1-9 16:57:47编辑过]