Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何将CSS样式应用于GridView中BoundField内的块/标记_C#_Html_Css_Asp.net_Vb.net - Fatal编程技术网

C# 如何将CSS样式应用于GridView中BoundField内的块/标记

C# 如何将CSS样式应用于GridView中BoundField内的块/标记,c#,html,css,asp.net,vb.net,C#,Html,Css,Asp.net,Vb.net,我有一个gridview: <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <style> .GridViewCell { display:inline-block; width:200; } </style> </h

我有一个gridview:

 <html xmlns="http://www.w3.org/1999/xhtml">
 <head runat="server">
    <title></title>
    <style> .GridViewCell 
            {
            display:inline-block; 
        width:200; } </style>
</head>
<body>
    <div>
    <asp:GridView ID="gvExportList" AutoGenerateColumns="false" AllowPaging="false" AllowSorting="false" runat="server" HeaderStyle-BackColor="LightGray">
            <Columns>
                <asp:BoundField DataField="ID" HeaderText="ID #" DataFormatString="&nbsp;{0}" />
                <asp:BoundField DataField="Date" HeaderText="Date" DataFormatString="{0:MM/dd/yyyy}" />
                <asp:BoundField DataField="Text" HeaderText="Text" />
    </Columns>
            </asp:GridView>
       </div>
</body>
</html>
使用
ItemStyle CSS
将CSS样式应用于整个字符串,而不是我想要的样式:

<ItemStyle CssClass="GridViewCell" />

输出:


也许只是&tab;会有帮助吗

或者,如果您希望每个单词在元素中隔开。 下面是一个用css/html实现的示例

css

html


同侧耳

参考资料:

您的最终HTML是什么样子的?asp.net为整个
gridview
或仅为文本字段生成的html…@Dekel?如果你只是指文本字段,它看起来就像我在上面最后展示的那样。asp.net生成html
@Dekel我添加了HTML代码。您只添加了
标记,而不是输出。。。
<ItemStyle CssClass="GridViewCell" />
div{
  background-color:gold;
  text-align:justify;
}

span{
  background-color:red;
  width:100%;
  height:1em;
  display:inline-block;
}
<div>
  Lorem ipsum sit dolor
  <span> </span>
</div>