求个方法啊:如何把数据库中的0,1,在GridView里边用“是”“否”表示啊? 怎么把数据库中的信息,读出梆定到GRIDVIEW里边的时候,把0,1,转成是否啊不需要用RADIOBUTTON,最好是和否字能用不同的颜色表示 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可以在拼SQL 的时候 case when 一下 。 在sql语句里面可以控制 stuSex= case stuSex when '0' then '男' else '女' end , protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { Label lblSex = (Label)e.Row.Cells[0].Controls[1]; if (lblSex == "0") lblSex.Text = "男"; else lblSex.Text = "女"; } } 在后台写个方法protected String ReplaceString(object o){ if(o == null || Convert.ToString(o) == String.Empty) { return String.Empty; } if(Convert.ToInt32(o) == 1) { return "<font color='red'>是</font>"; } else { return "<font color='blue'>否</font>"; }}在前台调用<%# ReplaceString(Eval("type"))%> 用函数也可以<%# publicPrograms.GetSex(Eval("sex").ToString())%>后台public static string GetSex(string sex) { if (sex == "1") { return "是"; } else { return "否"; } } } protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { Label lblSex = (Label)e.Row.Cells[0].Controls[1]; if (lblSex == "0") lblSex.Text = "男"; else lblSex.Text = "女"; } }这个比较好,还可以自己设颜色 lblSex.ForeColor=Color.Red 三人行采集数据后如何发到自己的论坛上去的呢? 2个问题,IE可以,火狐下执行不行 DataSet 该在什么时候使用(我真的不懂,请不要嘲笑偶) 倒计时程序问题 急,关于在装有.net的机子上运行javascript的问题 同一页面内容如何使用不用的配色方案显示出来? 简单问题 怎样格式化时间?(在线) 救命!!思归等大侠请进,分不够再加!! 急.WEB窗体的数据库问题 Infragistics.WebUI.UltraWebGrid.UltraWebGrid 的错误问题?(见者有分) !!!!在web页上加一链接到PDF文件,能不能让其内容显示出来,不出现下载对话框??
stuSex= case stuSex when '0' then '男' else '女' end ,
{ if (e.Row.RowType == DataControlRowType.DataRow)
{
Label lblSex = (Label)e.Row.Cells[0].Controls[1];
if (lblSex == "0")
lblSex.Text = "男";
else
lblSex.Text = "女";
}
}
protected String ReplaceString(object o)
{
if(o == null || Convert.ToString(o) == String.Empty)
{
return String.Empty;
} if(Convert.ToInt32(o) == 1)
{
return "<font color='red'>是</font>";
}
else
{
return "<font color='blue'>否</font>";
}
}
在前台调用<%# ReplaceString(Eval("type"))%>
<%# publicPrograms.GetSex(Eval("sex").ToString())%>后台
public static string GetSex(string sex)
{
if (sex == "1")
{
return "是";
}
else
{
return "否";
}
}
}
{ if (e.Row.RowType == DataControlRowType.DataRow)
{
Label lblSex = (Label)e.Row.Cells[0].Controls[1];
if (lblSex == "0")
lblSex.Text = "男";
else
lblSex.Text = "女";
}
}
这个比较好,还可以自己设颜色 lblSex.ForeColor=Color.Red