<ItemTemplate>
                <div class="Hr_title">
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("bookname") %>'></asp:Label>
                </div>
                <div class="Hr_content">              
                <asp:Label ID="Label2" runat="server" Text='<%# Bind("explain") %>'></asp:Label>
                </div>
            </ItemTemplate>.Hr_title
{
    font-size: 110%;
    font-weight: bold;
    line-height: 35px;
    text-align: left;
    text-indent: 15px;
    overflow: hidden;
    color: #333333;
    width: 100%;
    height: 35px;
    margin-bottom: 5px;
}
.Hr_content
{
    line-height: 30px;
    text-align: left;
    text-indent: 25px;
}在程序里面看是没问题的, 调试或放到服务器上就没作用了

解决方案 »

  1.   

    是不是有css的覆盖啊什么的情况发生
    应该是可以的
      

  2.   

    调试都没有问题啊
    default.aspx<%@ Page Language="VB" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"></script><html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>无标题页</title>
        <link href="StyleSheet.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
        <form id="form1" runat="server">
            <ItemTemplate>
                <div class="Hr_title">
                    <asp:Label ID="Label1" runat="server" Text='abc'></asp:Label>
                </div>
                <div class="Hr_content">              
                    <asp:Label ID="Label2" runat="server" Text='def'></asp:Label>
                </div>
            </ItemTemplate>     </form>
    </body>
    </html>
    stylesheet.cssbody {
    }
    .newStyle1
    {
    }
    .Hr_title
    {
        font-size: 110%;
        font-weight: bold;
        line-height: 35px;
        text-align: left;
        text-indent: 15px;
        overflow: hidden;
        color: #ff0000;
        width: 100%;
        height: 35px;
        margin-bottom: 5px;
    }
    .Hr_content
    {
        line-height: 30px;
        text-align: left;
        text-indent: 25px;
    }
      

  3.   


    楼主是不是设置了span的内容,label在客户端生成的html是span,可能是span样式被设置过了一般不需要使用label来显示数据了,这样生成多余的html代码,直接绑定就可以了         <ItemTemplate>
                    <div class="Hr_title">
                       <%# Bind("bookname") %>
                    </div>
                    <div class="Hr_content">              
                    <%# Bind("explain") %>
                    </div>
                </ItemTemplate>
      

  4.   

    兄弟,这样肯定没用的。<asp:TemplateField HeaderText="名称one">
                        <ItemTemplate>
                            <asp:Label ID="Label1" runat="server" Text='<%# Bind("bookname") %>'></asp:Label>
                        </ItemTemplate>
                        <ItemStyle CssClass="Hr_title" />
    </asp:TemplateField>
    <asp:TemplateField HeaderText="名称two">
                        <ItemTemplate>
                            <asp:Label ID="Label2" runat="server" Text='<%# Bind("explain") %>'></asp:Label>
                        </ItemTemplate>
                        <ItemStyle CssClass="Hr_content" />
    </asp:TemplateField>
      

  5.   

    <link href="StyleSheet.css" rel="stylesheet" type="text/css" />
      

  6.   

    看是不是被GridView自已的样式所覆盖了