Как исправить заголовок и подзаголовок в повторителе в ASP.NET - PullRequest
0 голосов
/ 02 ноября 2018

Как исправить заголовок и подзаголовок при прокрутке повторителя вверх или вниз, я пытаюсь с CSS (стиль) Ref. ссылка (https://www.aspdotnet -suresh.com / 2015/03 / aspnet-прокручиваемый-репитер-контроль-с-фиксированным-заголовком столбца-использованием-css-in-csharp-vbnet.html ) и что правильно работает для отдельного заголовка, но не для подзаголовка, есть ли способ сделать это?

Ретранслятор

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
    <script>
        $(document).ready(function () {

            $("table").prepend("<tr style=' color: white;  background-color: #9494b9;'> <th>Column 1</th><th colspan='2'>Column 2</th><th colspan='2'>Column 3</th></tr>")
        })
    </script>
    <style type="text/css">
        #rpttable tr td
        {
            max-height:10%;
            }
        table {
            border-collapse: collapse;
            text-align: center;
        }
    </style>

    <asp:Repeater ID="rptDrugs" runat="server" >
                    <HeaderTemplate>
                        <table border="1" id="rpttable">
                            <tr style=" color: white;  background-color: #9494b9;">
                                <th scope="col" style="width: 80px"> &nbsp;</th>
                                <th scope="col" style="width: 80px">Dosage
                                </th>
                                <th scope="col" style="width: 120px">Drug
                                </th>
                                <th scope="col" style="width: 100px">Patient
                                </th>
                                <th scope="col" style="width: 100px">Date
                                </th>
                            </tr>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <tr>
                            <td>
                                <asp:Label ID="Label2" runat="server" Text="" />
                            </td>
                            <td>
                                <asp:Label ID="lblCustomerId" runat="server" Text='<%# Eval("Dosage") %>' />
                            </td>
                            <td>
                                <asp:Label ID="lblContactName" runat="server" Text='<%# Eval("Drug") %>' />
                            </td>
                            <td>
                                <asp:Label ID="lblCountry" runat="server" Text='<%# Eval("Patient") %>' />
                            </td>
                            <td>
                                <asp:Label ID="Label1" runat="server" Text='<%# Eval("Date") %>' />
                            </td>
                        </tr>
                    </ItemTemplate>
                    <FooterTemplate>
                        </table>
                    </FooterTemplate>
                </asp:Repeater>

CS

protected void Page_Load(object sender, EventArgs e)
{
    DataTable table = new DataTable();
    table.Columns.Add("Dosage", typeof(int));
    table.Columns.Add("Drug", typeof(string));
    table.Columns.Add("Patient", typeof(string));
    table.Columns.Add("Date", typeof(DateTime));

    // Here we add five DataRows.
    table.Rows.Add(25, "Indocin", "David", DateTime.Now);
    table.Rows.Add(50, "Enebrel", "Sam", DateTime.Now);
    table.Rows.Add(10, "Hydralazine", "Christoff", DateTime.Now);
    table.Rows.Add(21, "Combivent", "Janet", DateTime.Now);
    table.Rows.Add(100, "Dilantin", "Melanie", DateTime.Now);
    rptDrugs.DataSource = table;
    rptDrugs.DataBind();
}
...