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"));
这样也没输出,怎么办?怎么取到值?有例子吗? 

解决方案 »

  1.   

    string nowDSN=ConfigurationSettings.AppSettings["data"];
    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;也不行
      

  2.   

    你前台数据是怎么绑定的?是不使用《%#%》的形式??有没有用table定位
    有的话,上边的都不行了,前台代码贴一下
      

  3.   

        <td width="50" align="center"> 
    <input size="5" value="<%# DataBinder.Eval(Container.DataItem, "status3") %>" readonly="true" tabindex="2" style="text-align=center;border:1px solid # 999999">
                  </td>这就是前台代码
      

  4.   

    if(e.Item.ItemType==ListItemType.Item||e.Item.ItemType==ListItemType.AlternatingItem||e.Item.ItemType==ListItemType.EditItem) (HtmlInputControl)e.Item.FindControl("jieguo1").Attributes.Add("bgcolor","red");  編譯器錯誤訊息: CS0201: 只有指派、呼叫、遞增、遞減和新增物件運算式可以當作陳述式使用
      

  5.   

    <input size="5" type='text' value='<%# DataBinder.Eval(Container.DataItem, "jieguo1") %>' id="jieguo1" readonly="true" tabindex="2" style="text-align=center;border:1px solid # 999999" runat="server"/>if(Convert.ToString(DataBinder.Eval(e.Item.DataItem,"jieguo1"))=="不合格")
    ((HtmlInputControl)e.Item.FindControl("jieguo1")).Attributes.Add("bgcolor","red");没反映
      

  6.   


    很简单呀在前台
    <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

      

  7.   

    在。net得帮助文件
    asp.net入门数据绑定关于如何绑定函数就有这方面得介绍,你可以去看看。net帮助