private void DL_Main_ItemDataBound(object sender, System.Web.UI.WebControls.DataListItemEventArgs e)
{
if(e.Item.ItemType==ListItemType.Item||e.Item.ItemType==ListItemType.AlternatingItem||e.Item.ItemType==ListItemType.EditItem)
if((string)DataBinder.Eval(e.Item.DataItem,"status3")=="0")
e.Item.BackColor=Color.Pink;
}前台的行的颜色没反映,也没提示错误Response.Write((string)DataBinder.Eval(e.Item.DataItem,"status3"));
这样也没输出,怎么办?怎么取到值?有例子吗?
{
if(e.Item.ItemType==ListItemType.Item||e.Item.ItemType==ListItemType.AlternatingItem||e.Item.ItemType==ListItemType.EditItem)
if((string)DataBinder.Eval(e.Item.DataItem,"status3")=="0")
e.Item.BackColor=Color.Pink;
}前台的行的颜色没反映,也没提示错误Response.Write((string)DataBinder.Eval(e.Item.DataItem,"status3"));
这样也没输出,怎么办?怎么取到值?有例子吗?
SqlConnection myConnection=new SqlConnection(nowDSN);
SqlDataAdapter myCommand=new SqlDataAdapter("SELECT * FROM Pur",myConnection);
DataSet ds = new DataSet();
myCommand.Fill(ds, "dingdan"); if ((ds.Tables[0].Rows[e.Item.ItemIndex]["status3"].ToString()) == "1")
e.Item.BackColor=Color.Pink;也不行
有的话,上边的都不行了,前台代码贴一下
<input size="5" value="<%# DataBinder.Eval(Container.DataItem, "status3") %>" readonly="true" tabindex="2" style="text-align=center;border:1px solid # 999999">
</td>这就是前台代码
((HtmlInputControl)e.Item.FindControl("jieguo1")).Attributes.Add("bgcolor","red");没反映
很简单呀在前台
<td width="50" align="center" bgcolor='<%#BgColor(DataBinder.Eva(Container.DataItem, "jieguo1")。ToString())%>'> 你在后台写一个函数比如说:叫:public string BgColor(string id){
string bgcolor;
if if=....
bgcolor = "red";
else if...
bgcolor = yellow
.....
return bgcolor
}
asp.net入门数据绑定关于如何绑定函数就有这方面得介绍,你可以去看看。net帮助