<ItemTemplate>
<%#
if(DataBinder.Eval(Container.DataItem, "news_status")==true)
{Response.Write("已审核");}
else
{Response.Write("未审核");}
%>
</ItemTemplate>那要怎样才有效呢?
<%#
if(DataBinder.Eval(Container.DataItem, "news_status")==true)
{Response.Write("已审核");}
else
{Response.Write("未审核");}
%>
</ItemTemplate>那要怎样才有效呢?
<asp:label id=Label5 runat="server" Text='<%#ChangStatushybv8((DataBinder.Eval(Container.DataItem, "news_status")).ToString())%>'>
</asp:label>
</ItemTemplate>在模板列里放个LABEL标签 调用后台这个方法 /// <summary>
/// 设置自定义文本值
/// </summary>
/// <param name="hy21">是否是优惠用户</param>
/// <returns>返回自定义文本</returns>
protected string ChangStatushy21(string hy21)
{
if(hy21 == "1")
{
return "已审核";
}
else if(hy21 == "0")
{
return "<font color=red>未审核</font>";
}
else
{
return "";
}
}
{
string strConn = "Provider=Microsoft.Jet.Oledb.4.0;Data Source=" + Server.MapPath("../"+System.Configuration.ConfigurationManager.AppSettings["MyData"]);
string Sql = "SELECT news_id,news_title,news_author,news_status,news_flag,news_time FROM news ORDER BY news_id DESC";
OleDbConnection Conn = new OleDbConnection(strConn);
OleDbDataAdapter myDataAdapter = new OleDbDataAdapter(Sql, Conn);
Conn.Open();
//填充数据库
myDataAdapter.Fill(myDS);
//绑定记录集
myDataGrid.DataSource = myDS;
myDataGrid.DataBind();
}我这种情况怎么搞啊,麻烦大伙了
CASE news_status when 1 then "已审核"
when 0 then "未审核"
,news_flag,news_time
FROM news ORDER
1。先在cs中寫函數
protected string GetVerifyStr(string orgStr)
{
string ret="";
if(Convert.ToBoolean(DataBinder.Eval(Container.DataItem, "news_status")))
{
ret="已审核";
}
else
{
ret="未审核";
}
return ret;
}然後在客戶端調用這個函數。<%#GetVerifyStr(DataBinder.Eval(Container.DataItem, "news_status").ToString())%>