<如何将 bool 转换为string 并显示在页面?>
谢谢!!
17 个解决方案
#1
Label1.Text=(myboolValue==true)?"是":"否";
myboolValue就是你从数据库中取出的bool值。
myboolValue就是你从数据库中取出的bool值。
#2
vb
dim if as booleam
dim l as string
if if= true then
l="是"
else
l="否"
end if
dim if as booleam
dim l as string
if if= true then
l="是"
else
l="否"
end if
#3
label1.Text=myboolValue?"是":"否";
#4
true.ToString()等等
#5
myboolValue是否需要在定义
如何定义它,下面代码如何改进!!!谢谢!
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using yxyfirClassLibrary;
namespace yxybdjianshen.anjianshouli
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label slaId;
protected System.Web.UI.WebControls.Label fir_sys1;
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
if (Request.Params ["slaId"]!=null)
{
string slaId1=Request.Params["slaId"];
if(slaId1!="")
{
string sql="select * from shouli_a where slaId="+slaId1;
readdb mydblink=new readdb();
DataTable tmptab=mydblink.getTab(sql);
if(tmptab.Rows.Count>0)
{
slaId.Text=tmptab.Rows[0]["slaId"].ToString();
fir_sys1.Text=myboolValue?"是":"否";
}
}
}
}
}
}
}
如何定义它,下面代码如何改进!!!谢谢!
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using yxyfirClassLibrary;
namespace yxybdjianshen.anjianshouli
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label slaId;
protected System.Web.UI.WebControls.Label fir_sys1;
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
if (Request.Params ["slaId"]!=null)
{
string slaId1=Request.Params["slaId"];
if(slaId1!="")
{
string sql="select * from shouli_a where slaId="+slaId1;
readdb mydblink=new readdb();
DataTable tmptab=mydblink.getTab(sql);
if(tmptab.Rows.Count>0)
{
slaId.Text=tmptab.Rows[0]["slaId"].ToString();
fir_sys1.Text=myboolValue?"是":"否";
}
}
}
}
}
}
}
#6
这样改:
在你的shouli_a 表中应该有一个字段是bool那你把他去出来,
if(tmptab.Rows.Count>0)
{
slaId.Text=tmptab.Rows[0]["slaId"].ToString();
myboolvalue=tmptab.Rows[0]["yourBoolValue"].ToString();
fir_sys1.Text=myboolValue?"是":"否";
}
在你的shouli_a 表中应该有一个字段是bool那你把他去出来,
if(tmptab.Rows.Count>0)
{
slaId.Text=tmptab.Rows[0]["slaId"].ToString();
myboolvalue=tmptab.Rows[0]["yourBoolValue"].ToString();
fir_sys1.Text=myboolValue?"是":"否";
}
#7
当然要,要不你怎么把数据库中的值传给myboolValue(你定义的一个变量而已)!
#8
名称“myboolvalue”在类或命名空间"yxybdjianshen.anjianshouli.webform1"中不存在!!!
fir_sys1就是shouli_a表中的字段!
myboolvalue=tmptab.Rows[0]["fir_sys1"].ToString();
fir_sys1.Text=myboolValue?"是":"否";
fir_sys1就是shouli_a表中的字段!
myboolvalue=tmptab.Rows[0]["fir_sys1"].ToString();
fir_sys1.Text=myboolValue?"是":"否";
#9
告诉我怎么写好吗?我不会!谢谢你!!!
#10
你select 完了调用SqlDataReader reader=myCommand.ExecuteReader();
reader.Read();
然后 myboolvalue = reader["fir_sysl"].ToString();
fir_sysl.Text = myboolvalue ?"是":"否";
reader.Read();
然后 myboolvalue = reader["fir_sysl"].ToString();
fir_sysl.Text = myboolvalue ?"是":"否";
#11
你有qq吗?值结合你讨教!怎样?
回复 mjzcyber(mjzcyber)
我的qq:260153351
回复 mjzcyber(mjzcyber)
我的qq:260153351
#12
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
if (Request.Params ["slaId"]!=null)
{
string slaId1=Request.Params["slaId"];
if(slaId1!="")
{
string sql="select * from shouli_a where slaId="+slaId1;
SqlConnection sqlConn=new SqlConnection (strConn);
SqlCommand sqlComm=new SqlComm(sql,sqlConn)
SqlDataReader sqlRead = null;
sqlConn.open;
sqlRead=sqlComm.ExcuetRead()
if(sqlRead.Read())
{
myboolValue=tmptab.Rows[0]["youBoolValue"].ToString();
fir_sys1.Text=myboolValue?"是":"否";
}
}
}
}
}
}
}
{
if(!Page.IsPostBack)
{
if (Request.Params ["slaId"]!=null)
{
string slaId1=Request.Params["slaId"];
if(slaId1!="")
{
string sql="select * from shouli_a where slaId="+slaId1;
SqlConnection sqlConn=new SqlConnection (strConn);
SqlCommand sqlComm=new SqlComm(sql,sqlConn)
SqlDataReader sqlRead = null;
sqlConn.open;
sqlRead=sqlComm.ExcuetRead()
if(sqlRead.Read())
{
myboolValue=tmptab.Rows[0]["youBoolValue"].ToString();
fir_sys1.Text=myboolValue?"是":"否";
}
}
}
}
}
}
}
#13
Label1.Text = ((bool)dr["BoolColumn"]) == true ? "是" : "否";
#14
你 按照houlinghouling(新玲)的做法作一次,我的和他的差不多。
#15
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
string slaId1=Request.Params["slaId"];
if (slaIdl!=null)
{
string sql="select * from shouli_a where slaId="+slaId1;
readdb mydblink=new readdb();
DataTable tmptab=mydblink.getTab(sql);
if(tmptab.Rows.Count>0)
{
slaId.Text=tmptab.Rows[0]["slaId"].ToString();
bool myboolValue=(bool)temtab.Rows[0]["bit类型字段名"];
fir_sys1.Text=myboolValue?"是":"否";
}
}
}
}
{
if(!Page.IsPostBack)
{
string slaId1=Request.Params["slaId"];
if (slaIdl!=null)
{
string sql="select * from shouli_a where slaId="+slaId1;
readdb mydblink=new readdb();
DataTable tmptab=mydblink.getTab(sql);
if(tmptab.Rows.Count>0)
{
slaId.Text=tmptab.Rows[0]["slaId"].ToString();
bool myboolValue=(bool)temtab.Rows[0]["bit类型字段名"];
fir_sys1.Text=myboolValue?"是":"否";
}
}
}
}
#16
谢谢各位!问题已解决!!!代码如下:
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
if (Request.Params ["slaId"]!=null)
{
string slaId1=Request.Params["slaId"];
if(slaId1!="")
{
string sql="select * from shouli_a where slaId="+slaId1;
bool myboolvalue;
readdb mydblink=new readdb();
DataTable tmptab=mydblink.getTab(sql);
if(tmptab.Rows.Count>0)
{
slaId.Text=tmptab.Rows[0]["slaId"].ToString();
myboolvalue=bool.Parse(tmptab.Rows[0]["fir_system"].ToString());
if (myboolvalue)
{
fir_system.Text="是 ";
}
else
{
fir_system.Text="否";
}
}
}
}
}
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
if (Request.Params ["slaId"]!=null)
{
string slaId1=Request.Params["slaId"];
if(slaId1!="")
{
string sql="select * from shouli_a where slaId="+slaId1;
bool myboolvalue;
readdb mydblink=new readdb();
DataTable tmptab=mydblink.getTab(sql);
if(tmptab.Rows.Count>0)
{
slaId.Text=tmptab.Rows[0]["slaId"].ToString();
myboolvalue=bool.Parse(tmptab.Rows[0]["fir_system"].ToString());
if (myboolvalue)
{
fir_system.Text="是 ";
}
else
{
fir_system.Text="否";
}
}
}
}
}
#17
不给分??
#1
Label1.Text=(myboolValue==true)?"是":"否";
myboolValue就是你从数据库中取出的bool值。
myboolValue就是你从数据库中取出的bool值。
#2
vb
dim if as booleam
dim l as string
if if= true then
l="是"
else
l="否"
end if
dim if as booleam
dim l as string
if if= true then
l="是"
else
l="否"
end if
#3
label1.Text=myboolValue?"是":"否";
#4
true.ToString()等等
#5
myboolValue是否需要在定义
如何定义它,下面代码如何改进!!!谢谢!
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using yxyfirClassLibrary;
namespace yxybdjianshen.anjianshouli
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label slaId;
protected System.Web.UI.WebControls.Label fir_sys1;
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
if (Request.Params ["slaId"]!=null)
{
string slaId1=Request.Params["slaId"];
if(slaId1!="")
{
string sql="select * from shouli_a where slaId="+slaId1;
readdb mydblink=new readdb();
DataTable tmptab=mydblink.getTab(sql);
if(tmptab.Rows.Count>0)
{
slaId.Text=tmptab.Rows[0]["slaId"].ToString();
fir_sys1.Text=myboolValue?"是":"否";
}
}
}
}
}
}
}
如何定义它,下面代码如何改进!!!谢谢!
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using yxyfirClassLibrary;
namespace yxybdjianshen.anjianshouli
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label slaId;
protected System.Web.UI.WebControls.Label fir_sys1;
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
if (Request.Params ["slaId"]!=null)
{
string slaId1=Request.Params["slaId"];
if(slaId1!="")
{
string sql="select * from shouli_a where slaId="+slaId1;
readdb mydblink=new readdb();
DataTable tmptab=mydblink.getTab(sql);
if(tmptab.Rows.Count>0)
{
slaId.Text=tmptab.Rows[0]["slaId"].ToString();
fir_sys1.Text=myboolValue?"是":"否";
}
}
}
}
}
}
}
#6
这样改:
在你的shouli_a 表中应该有一个字段是bool那你把他去出来,
if(tmptab.Rows.Count>0)
{
slaId.Text=tmptab.Rows[0]["slaId"].ToString();
myboolvalue=tmptab.Rows[0]["yourBoolValue"].ToString();
fir_sys1.Text=myboolValue?"是":"否";
}
在你的shouli_a 表中应该有一个字段是bool那你把他去出来,
if(tmptab.Rows.Count>0)
{
slaId.Text=tmptab.Rows[0]["slaId"].ToString();
myboolvalue=tmptab.Rows[0]["yourBoolValue"].ToString();
fir_sys1.Text=myboolValue?"是":"否";
}
#7
当然要,要不你怎么把数据库中的值传给myboolValue(你定义的一个变量而已)!
#8
名称“myboolvalue”在类或命名空间"yxybdjianshen.anjianshouli.webform1"中不存在!!!
fir_sys1就是shouli_a表中的字段!
myboolvalue=tmptab.Rows[0]["fir_sys1"].ToString();
fir_sys1.Text=myboolValue?"是":"否";
fir_sys1就是shouli_a表中的字段!
myboolvalue=tmptab.Rows[0]["fir_sys1"].ToString();
fir_sys1.Text=myboolValue?"是":"否";
#9
告诉我怎么写好吗?我不会!谢谢你!!!
#10
你select 完了调用SqlDataReader reader=myCommand.ExecuteReader();
reader.Read();
然后 myboolvalue = reader["fir_sysl"].ToString();
fir_sysl.Text = myboolvalue ?"是":"否";
reader.Read();
然后 myboolvalue = reader["fir_sysl"].ToString();
fir_sysl.Text = myboolvalue ?"是":"否";
#11
你有qq吗?值结合你讨教!怎样?
回复 mjzcyber(mjzcyber)
我的qq:260153351
回复 mjzcyber(mjzcyber)
我的qq:260153351
#12
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
if (Request.Params ["slaId"]!=null)
{
string slaId1=Request.Params["slaId"];
if(slaId1!="")
{
string sql="select * from shouli_a where slaId="+slaId1;
SqlConnection sqlConn=new SqlConnection (strConn);
SqlCommand sqlComm=new SqlComm(sql,sqlConn)
SqlDataReader sqlRead = null;
sqlConn.open;
sqlRead=sqlComm.ExcuetRead()
if(sqlRead.Read())
{
myboolValue=tmptab.Rows[0]["youBoolValue"].ToString();
fir_sys1.Text=myboolValue?"是":"否";
}
}
}
}
}
}
}
{
if(!Page.IsPostBack)
{
if (Request.Params ["slaId"]!=null)
{
string slaId1=Request.Params["slaId"];
if(slaId1!="")
{
string sql="select * from shouli_a where slaId="+slaId1;
SqlConnection sqlConn=new SqlConnection (strConn);
SqlCommand sqlComm=new SqlComm(sql,sqlConn)
SqlDataReader sqlRead = null;
sqlConn.open;
sqlRead=sqlComm.ExcuetRead()
if(sqlRead.Read())
{
myboolValue=tmptab.Rows[0]["youBoolValue"].ToString();
fir_sys1.Text=myboolValue?"是":"否";
}
}
}
}
}
}
}
#13
Label1.Text = ((bool)dr["BoolColumn"]) == true ? "是" : "否";
#14
你 按照houlinghouling(新玲)的做法作一次,我的和他的差不多。
#15
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
string slaId1=Request.Params["slaId"];
if (slaIdl!=null)
{
string sql="select * from shouli_a where slaId="+slaId1;
readdb mydblink=new readdb();
DataTable tmptab=mydblink.getTab(sql);
if(tmptab.Rows.Count>0)
{
slaId.Text=tmptab.Rows[0]["slaId"].ToString();
bool myboolValue=(bool)temtab.Rows[0]["bit类型字段名"];
fir_sys1.Text=myboolValue?"是":"否";
}
}
}
}
{
if(!Page.IsPostBack)
{
string slaId1=Request.Params["slaId"];
if (slaIdl!=null)
{
string sql="select * from shouli_a where slaId="+slaId1;
readdb mydblink=new readdb();
DataTable tmptab=mydblink.getTab(sql);
if(tmptab.Rows.Count>0)
{
slaId.Text=tmptab.Rows[0]["slaId"].ToString();
bool myboolValue=(bool)temtab.Rows[0]["bit类型字段名"];
fir_sys1.Text=myboolValue?"是":"否";
}
}
}
}
#16
谢谢各位!问题已解决!!!代码如下:
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
if (Request.Params ["slaId"]!=null)
{
string slaId1=Request.Params["slaId"];
if(slaId1!="")
{
string sql="select * from shouli_a where slaId="+slaId1;
bool myboolvalue;
readdb mydblink=new readdb();
DataTable tmptab=mydblink.getTab(sql);
if(tmptab.Rows.Count>0)
{
slaId.Text=tmptab.Rows[0]["slaId"].ToString();
myboolvalue=bool.Parse(tmptab.Rows[0]["fir_system"].ToString());
if (myboolvalue)
{
fir_system.Text="是 ";
}
else
{
fir_system.Text="否";
}
}
}
}
}
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
if (Request.Params ["slaId"]!=null)
{
string slaId1=Request.Params["slaId"];
if(slaId1!="")
{
string sql="select * from shouli_a where slaId="+slaId1;
bool myboolvalue;
readdb mydblink=new readdb();
DataTable tmptab=mydblink.getTab(sql);
if(tmptab.Rows.Count>0)
{
slaId.Text=tmptab.Rows[0]["slaId"].ToString();
myboolvalue=bool.Parse(tmptab.Rows[0]["fir_system"].ToString());
if (myboolvalue)
{
fir_system.Text="是 ";
}
else
{
fir_system.Text="否";
}
}
}
}
}
#17
不给分??