asp 还是 asp.net  ?

解决方案 »

  1.   

    我想你是想显示在Datagrid里,使用自定义函数来显示记录
    <asp:DataGrid id="DataGrid1" runat="server" AutoGenerateColumns="False" Width="760px">
    <asp:TemplateColumn>
    <HeaderStyle BackColor="#FFCC66"></HeaderStyle>
    <ItemTemplate>
    <asp:Label runat="server" Text='<%# ShowBook(DataBinder.Eval(Container, "DataItem.BookName")) %>' ID="Label4">
    </asp:Label>
    </ItemTemplate>
    </asp:TemplateColumn>
    </asp:DataGrid>
    cs.
    public string ShowBook(string bookname)
    {
     string tempbookname=""; switch(bookname)
    {
      case "文学类": 
          tempbookname="<font color='red'>文学类</font>";
           break;
      case "科技类":
          tempbookname="<font color='white'>科技类</font>";
            break;
    }
     return tempbookname;
    }
     
    }