<%# (bool)DataBinder.Eval(Container, "DataItem.sex")? "男" : "女" %>

解决方案 »

  1.   

    <%# (bool)DataBinder.Eval(Container, "DataItem.sex")? "男" : "女" %>
      

  2.   

    在cs文件一下函数
    public string showit(string a){
    if (a=="1") return "女";
    else return "男";
    }
    绑定:
    <%# showit(DataBinder.Eval(Container.DataItem, "CustomerID").ToString()) %>
      

  3.   

    用XML文件!但是原理和Database是一样的!
    但是灵活性更好一些!上面的方法如果又变化则必须修改Source code后在编译!
    如果用数据库或者XML则不用这么麻烦!
      

  4.   

    在DataGrid中让不同条件的行显示不同的背景颜色?
    通过如下方法做时:在DataGrid的ItemDataBind事件里写
    if((e.Item.Cells[6].Text)=="男")//假设性别字段在第6行
      e.Item.BackColor=Color.Blue;
    if((e.Item.Cells[6].Text)=="女")
      e.Item.BackColor=Color.Red;
      

  5.   

    If Datagrid1.items(i).cell(j).text="m" then
    Datagrid1.items(i).cell(j).text="男"
    ElseIf Datagrid1.items(i).cell(j).text="f" then
    Datagrid1.items(i).cell(j).text="女"
    End If或用模板列里放 DropDownList DropDownList ddl = (DropDownList)sender;
      TableCell cell = (TableCell)ddl.Parent;
      DataGridItem item = (DataGridItem)cell.Parent;
      Response.Write(item.Cells[0].Text);
      

  6.   

    vb:
    public string showit(string a)
    begin
    if (a="1") then
     showit="女"
    else 
    showit="男"
    end
    绑定:
    <%# showit(DataBinder.Eval(Container.DataItem, "CustomerID").ToString()) %>