111,130
社区成员
发帖
与我相关
我的任务
分享image.bad
{
border-right: red solid;
border-top: red solid;
border-left: red solid;
border-bottom: red solid;
}
image.good
{
}
image.maintain
{
border-right: yellow solid;
border-top: yellow solid;
border-left: yellow solid;
border-bottom: yellow solid;
}
在数据库中建立了一个状态表,记录图片所处的状态,good、bad、maintain;当载入页面时,我做了一个循环,判断状态表的值,根据值调用样式表的内容,代码如下:
protected void css()
{
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
string sql = "select sb_id from view_state";
SqlDataAdapter sda = new SqlDataAdapter(sql, con);
DataSet ds = new DataSet();
sda.Fill(ds);
int i;
for(i=0;i <ds.Tables[0].Rows.Count;i++)
{
con.Open();
string strsql = "select st_good,st_maintain,st_bad from sb_state where sb_id="+i;
SqlDataAdapter stsda = new SqlDataAdapter(strsql, con);
DataSet stds = new DataSet();
stsda.Fill(stds);
//if (stds.Tables[0].Rows[i][0].ToString() == '1')
//{
// //调用image.good
//}
//else if (stds.Tables[0].Rows[i][1].ToString() == '1')
//{
// //调用image.maintain
//}
//else if (stds.Tables[0].Rows[i][2].ToString() == '1')
//{
// //调用image.bad
//}
con.Close();
}
} 其中被屏蔽的那部分判断和调用的语句写得有问题,请高手指点应该怎么改?