根据标志在 gridview 列中显示多个字形

Display multiple glyphicon's in gridview column based on flags

我有一个带有边界字段的网格视图。在第一列 "Priority" 中,我想绑定优先级编号,但也根据数据表中其他列的标志添加多个字形。有 "HOT_FLAG"、"WATCH_FLAG" 和 "INFO_FLAG" 列,如果这些是真的,我需要显示相应的字形。

<asp:GridView 
        ID="dgv_Test" 
        GridLines="None"
        AutoGenerateColumns="False"
        OnRowCreated="dgv_RowCreated"
        EnableHeadervisualstyles ="true"
        runat="server">
        <Columns>
            <asp:BoundField DataField="PRIORITY" HeaderText="#"/>
            <asp:BoundField DataField="COL2" HeaderText="COL2" />
            <asp:BoundField DataField="COL3" HeaderText="COL3" />
        </Columns>
</asp:GridView>

我假设我需要将这些绑定字段转换为模板字段(或其他内容)并在后面的代码中设置 Glyphicon,但我不确定从这里去哪里。

试试这个。

<asp:TemplateField HeaderText="#">
    <ItemTemplate>
        <asp:Image ID="HotFlag" runat="server" ImageUrl="path/to/image" Visible='<%# Eval("HOT_FLAG") %>'/>
        <asp:Image ID="WatchFlag" runat="server" ImageUrl="path/to/image" Visible='<%# Eval("WATCH_FLAG") %>'/>
        <asp:Image ID="InfoFlag" runat="server" ImageUrl="path/to/image" Visible='<%# Eval("INFO_FLAG") %>' />
    </ItemTemplate>
</asp:TemplateField>