我想判断GridView中的第一列的值,如果该值为“数据结构”,就用红色显示。
我的代码是
protected void GV_CourseList_RowDataBound1(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.Cells[0].Text == "数据结构")
{
e.Row.Cells[0].ForeColor=System.Drawing.Color.Red;
}
Response.Write(e.Row.Cells[0].Text);//测试一下
}
}
当数据源是用sqldatasource时就可以正常显示,但用dataset作为数据源时,数据能够在gridview中正常显示,但颜色没有变化。写了一个Response.Write的语句,结果里面的内容都为空,所以颜色判断不出来。
请教个位高手是怎么回事?我就是想用自己的dataset作为数据源,怎么解决?谢谢啦~~~~~~~
我的代码是
protected void GV_CourseList_RowDataBound1(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.Cells[0].Text == "数据结构")
{
e.Row.Cells[0].ForeColor=System.Drawing.Color.Red;
}
Response.Write(e.Row.Cells[0].Text);//测试一下
}
}
当数据源是用sqldatasource时就可以正常显示,但用dataset作为数据源时,数据能够在gridview中正常显示,但颜色没有变化。写了一个Response.Write的语句,结果里面的内容都为空,所以颜色判断不出来。
请教个位高手是怎么回事?我就是想用自己的dataset作为数据源,怎么解决?谢谢啦~~~~~~~
解决方案 »
- asp 关于Datalist绑定的问题
- .NET网站架构,IIS配置问题!救救我啊!
- webcombo控件,智能筛选如何能同时筛选两个字段??
- 用Vss时候得问题:有时候会比较历史记录得不同会出现Binary files differ 然后就不能比较这是为什么?怎么解决?
- 求一简单SQl
- 100分问个抓网页的问题。高手请进!
- 【求助】DIV右键弹出子菜单如何制作?
- 如何使用工程中內嵌的圖片資源.UP有分!
- datagrid中如何绑定和读取嵌入的html控件?
- post模拟登陆 教务系统 有一个参数随着密码变化,不解求助
- “System.Configuration.ConfigurationSettings”并不包含对“AppSetin
- SQL查询语句,可不可以指定这样的排序?
{
//GridView1.Rows[1].Cells[0].ForeColor = "red";
if (e.Row.RowType == DataControlRowType.DataRow)
{
string unitsInStock = DataBinder.Eval(e.Row.DataItem, "type").ToString();
if (Convert.ToInt32(unitsInStock) == 1)
{
e.Row.BackColor = System.Drawing.Color.FromArgb(158, 205, 237);
}
string unitsInStock1 = DataBinder.Eval(e.Row.DataItem, "lanaguagetype").ToString();
if (Convert.ToInt32(unitsInStock1) == 2)
{
e.Row.BackColor = System.Drawing.Color.FromArgb(170, 205, 240);
}
string unitsInStock2 = DataBinder.Eval(e.Row.DataItem, "lanatype").ToString();
if (Convert.ToInt32(unitsInStock2) == 3)
{
e.Row.BackColor = System.Drawing.Color.FromArgb(180, 220, 230);
} }
不会是调用错了吧 为什么后面会多了个一 如果是自动生成的话 应该是
GV_CourseList_RowDataBound断点跟进去看看 我去试试试试试试试试试
dataset 作为数据源可以将数据正常显示在gridview上,我想应该不会错吧。
xingxing2378(菜猩):你试了吗,可以显示吗?