不想在数据表中添加列名

发布于 2024-10-06 01:21:22 字数 94 浏览 0 评论 0原文

我正在做这样的事情 dt.Columns.Add("SomeCoumnName"); 但我不想在将其绑定到 gridview 后显示该列名称。 只是想显示特定列的空白标题。

I am doing something like this
dt.Columns.Add("SomeCoumnName");
But I don't want to display this column name after binding it to the gridview.
Just want to show a blank header for particular column.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甜`诱少女 2024-10-13 01:21:22

在 Gridview 中设置 AutoGenerateColumns="false" 并创建自定义标题,如给定示例中所示。如果您不想显示特定列的标题,请在中设置 HeaderText=""

<asp:GridView ID="grdSearch" runat="server" AutoGenerateColumns="False">            
            <Columns>                
                <asp:BoundField HeaderText="County" 
                  DataField="Prop_County" SortExpression="Prop_County" ItemStyle-Width="70px" HeaderStyle-Height="25px">                    
                </asp:BoundField>                
                <asp:BoundField HeaderText="Sale Date" 
                  DataField="Prop_Sale_Date" ItemStyle-Width="55px"></asp:BoundField>
                <asp:BoundField HeaderText="Sale Time" 
                  DataField="Prop_Sale_Time" ItemStyle-Width="55px"></asp:BoundField>                
                <asp:BoundField HeaderText="Bid Amount" 
                  DataField="Prop_Bid_Amnt" ItemStyle-Width="100px"></asp:BoundField>                
            </Columns>
</asp:GridView>    

Set AutoGenerateColumns="false" in Gridview and create custom header like in given sample. If you don't want to show header for a particular column then set HeaderText="" in <asp:BoundField ...>

<asp:GridView ID="grdSearch" runat="server" AutoGenerateColumns="False">            
            <Columns>                
                <asp:BoundField HeaderText="County" 
                  DataField="Prop_County" SortExpression="Prop_County" ItemStyle-Width="70px" HeaderStyle-Height="25px">                    
                </asp:BoundField>                
                <asp:BoundField HeaderText="Sale Date" 
                  DataField="Prop_Sale_Date" ItemStyle-Width="55px"></asp:BoundField>
                <asp:BoundField HeaderText="Sale Time" 
                  DataField="Prop_Sale_Time" ItemStyle-Width="55px"></asp:BoundField>                
                <asp:BoundField HeaderText="Bid Amount" 
                  DataField="Prop_Bid_Amnt" ItemStyle-Width="100px"></asp:BoundField>                
            </Columns>
</asp:GridView>    
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文