0

ASP.NET アプリケーションがあり、ListView. これListViewには行と列があります。列は、Firstname、Lastname、email などです。Controlこの中のすべてListViewLinkButton.

私の考え:

ユーザーが の上にマウスを移動すると、その行LinkButtonに別の が表示BackroundColorされます。

例えば:

ここに画像の説明を入力

私のコード:

aspx:

<body>
    <form id="form1" runat="server">
    <div class="header">
        <br />
        <table id="SuchTabelle" runat="server" border="0">

            <tr>
                <th><asp:Label ID="id_SearchUser" runat="server" Text="lblSearchUser"></asp:Label></th>
                <th><asp:TextBox ID="txtBenutzer" runat="server" Width="250px"></asp:TextBox></th>
                <th></th>
            </tr>
            <tr>
                <th><asp:Label ID="id_location" runat="server" Text="lblLocation"></asp:Label></th>
                <th><asp:DropDownList ID="dropWerk" runat="server" Width="250px" /></th>
                <th><asp:Button ID="Button2" runat="server" Text="Suchen" 
                                onclick="btnBenutzerSuchen_Click" Width="250" /></th>
            </tr>

        </table>

        <br />
        <br />
       <b>&nbsp;&nbsp;&nbsp; Info:</b> 
        <asp:Label ID="lbMeldung" runat="server" 
            Text="Geben Sie den Kontakt ein, nachdem gesucht werden soll..."></asp:Label>
        <br />
      <br />
      </div>

      <div class="bodyList">


        <asp:ListView runat="server" ID="myListView">

        <LayoutTemplate>
            <table id="UserTable" runat="server" border="0">
                <tr id="Tr1" style="background-color:#E5E5FE">
                    <th runat="server"><asp:LinkButton ID="lnkBenutzer" runat="server" >id_Benutzer</asp:LinkButton></th>
                    <th runat="server"><asp:LinkButton ID="lnkemail" runat="server" >id_Email</asp:LinkButton></th>
                    <th runat="server"><asp:LinkButton ID="lnkVorname" runat="server" >id_Vorname</asp:LinkButton></th>
                    <th runat="server"><asp:LinkButton ID="lnkNachname" runat="server" >id_Nachname</asp:LinkButton></th>
                    <th runat="server"><asp:LinkButton ID="lnkTelefon" runat="server" >id_Telefon</asp:LinkButton></th>
                </tr>
                <tr runat="server" id="ItemPlaceholder">
                </tr>
            </table>
        </LayoutTemplate>

        <ItemTemplate>

            <tr>    
                <td align="left" ><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label1" Text='<%# Eval("Benutzername") %>' runat="server" /></td>
                <td align="left"><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label2" Text='<%# Eval("eMail") %>' runat="server" /></td>
                <td align="left"><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label3" Text='<%# Eval("Vorname") %>' runat="server" /></td>
                <td align="left"><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label4" Text='<%# Eval("Nachname") %>' runat="server" /></td>
                <td align="left"><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label5" Text='<%# Eval("Telefonnummer") %>' runat="server" /></td>

              <td align="left"><asp:Label ID="Label6" Text='<%# Eval("GUID") %>' runat="server" Visible="False" /></td>

            </tr>

        </ItemTemplate>

        <AlternatingItemTemplate>

            <tr style="background-color:#EFEFEF"> 

                <td align="left" ><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label1" Text='<%# Eval("Benutzername") %>' runat="server" /></td>
                <td align="left"><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label2" Text='<%# Eval("eMail") %>' runat="server" /></td>
                <td align="left"><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label3" Text='<%# Eval("Vorname") %>' runat="server" /></td>
                <td align="left"><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label4" Text='<%# Eval("Nachname") %>' runat="server" /></td>
                <td align="left"><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label5" Text='<%# Eval("Telefonnummer") %>' runat="server" /></td>

                <td align="left"><asp:Label ID="Label6" Text='<%# Eval("GUID") %>' runat="server" Visible="False" /></td>

            </tr>

        </AlternatingItemTemplate>

        </asp:ListView>

        <br />
        <br />

    </div>

    </form>
</body>
4

1 に答える 1

1

CSS を使用できます。

<LayoutTemplate>
    <table id="UserTable" runat="server" class="myClass">
        <tr id="Tr1" class="myClass">
            <th id="Th1" runat="server">
                <asp:LinkButton ID="lnkBenutzer" runat="server" Text="id_Benutzer" />
            </th>
            <th id="Th2" runat="server">
                <asp:LinkButton ID="lnkemail" runat="server" Text="id_Email" />
            </th>
            <th id="Th3" runat="server">
                <asp:LinkButton ID="lnkVorname" runat="server" Text="id_Vorname" />
            </th>
            <th id="Th4" runat="server">
                <asp:LinkButton ID="lnkNachname" runat="server" Text="id_Nachname" />
            </th>
            <th id="Th5" runat="server">
                <asp:LinkButton ID="lnkTelefon" runat="server" Text="id_Telefon" />
            </th>
        </tr>
        <tr runat="server" id="ItemPlaceholder">
        </tr>
    </table>
</LayoutTemplate> 

および *.css ファイル内:

.myClass
{

}

.myClass:hover
{
background-color: Green;
}
于 2012-08-07T12:50:20.007 に答える