【问题标题】:I am trying to add bootstrap active class to the asp.net gridview row我正在尝试将引导活动类添加到 asp.net gridview 行
【发布时间】:2015-03-29 00:48:10
【问题描述】:

我正在尝试将活动类添加到 GridView。一旦我在网格中选择了一行,我想使用 Bootstrap 将其设置为选中状态。以前人们可能会问过它。但我找不到这个。

网格视图:

<div class="row">
    <asp:UpdatePanel ID="UpdatePanelGrid" runat="server">
        <ContentTemplate>
            <div class="history-table ">
                <asp:GridView CssClass="col-lg-6 col-md-8 col-sm-10 col-xs-12" DataKeyNames="HistoryId" ID="gvFunds" runat="server"
                    AutoGenerateColumns="False" OnSelectedIndexChanged="gvFunds_SelectedIndexChanged" OnRowDataBound="gvFunds_RowDataBound">
                    <Columns>
                        <asp:BoundField DataField="HistoryId" Visible="false" />
                        <asp:BoundField DataField="Date" HeaderText="Date" ReadOnly="True" />
                        <asp:BoundField DataField="Time" HeaderText="Time" ReadOnly="True" />
                        <asp:BoundField DataField="UserId" HeaderText="User ID" ReadOnly="True" />
                    </Columns>
                </asp:GridView>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
</div>

CSS:

.history-table table {
    text-align: center;
    border: none;
}

    .history-table table tr:nth-child(2n+1) {
        background-color: #C6C0AA;
    }

    .history-table table tr th {
        text-align: center;
        height: 35px;
        border: none;
        background-color: #C6C0AA;
    }

    .history-table table td {
        height: 25px;
        border: none;
    }

    .history-table table tr:hover {
        background-color: #8A2A2A;
        color: #FFF;
        cursor: pointer;
    }

    .history-table table tr:first-child:hover {
        color: #000;
    }

【问题讨论】:

    标签: asp.net c#-4.0 gridview twitter-bootstrap-3


    【解决方案1】:

    在尝试了很多方法后,我终于得到了答案。我可以使用 GridView 属性轻松完成。我在这里分享给大家参考。

    <div class="row" style="margin: 0px;">
            <asp:UpdatePanel ID="UpdatePanelGrid" runat="server">
                <ContentTemplate>
                    <div class="gridview-table ">
                        <asp:GridView CssClass="col-xs-12 gridview-with-default-selected-row" DataKeyNames="HistoryId" ID="gvFunds" ClientIDMode="Static" runat="server" ViewStateMode = "Enabled"
                            AutoGenerateColumns="False" OnSelectedIndexChanged="gvFunds_SelectedIndexChanged" OnRowDataBound="gvFunds_RowDataBound">
                            <FooterStyle ForeColor="#330099" BackColor="#FFFFCC"></FooterStyle>
                            <SelectedRowStyle Font-Bold="True" BackColor="#8a2a2a" ForeColor="White"></SelectedRowStyle>
                            <AlternatingRowStyle BackColor="White" ForeColor="Black" />
                            <RowStyle BackColor="#CDC7B1" BorderStyle="None" Height="30px" ></RowStyle>
                            <HeaderStyle Height="30px" BackColor="#F5F4EF" BorderColor="#F5F4EF" Font-Names="vegurregular" Font-Size="12px" Font-Bold="False"></HeaderStyle>
                            <Columns>
                                <asp:BoundField DataField="HistoryId" HeaderText="History ID" />
                                <asp:BoundField DataField="Date" HeaderText="Date" ReadOnly="True" />
                                <asp:BoundField DataField="Time" HeaderText="Time" ReadOnly="True" />
                                <asp:BoundField DataField="UserId" HeaderText="User ID" ReadOnly="True" />
                            </Columns>
                        </asp:GridView>
                    </div>
                </ContentTemplate>
            </asp:UpdatePanel>
        </div>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-03
      • 1970-01-01
      • 1970-01-01
      • 2016-12-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多