3

私は次のコードを持っています...

<asp:DetailsView ID="dvApprenticeship" runat="server" DataSourceID="dsApprenticeship" AutoGenerateRows="false" BackColor="#E0E8F0" GridLines="None" CellPadding="2"
    DataKeyNames="ProgramID, ProgramName, OrganisationName, StudyYearID, Workgroup, Pathway, FinishDate" OnDataBound="Apprenticeship_DataBound">
    <Fields>
        <asp:BoundField DataField="ProgramName" HeaderText="Program:" />
        <asp:BoundField DataField="StudyYearName" HeaderText="Study Year:" />
        <asp:HyperLinkField DataTextField="OrganisationName" HeaderText="Apprenticeship:&nbsp;" NavigateUrl="Apprenticeships.aspx" />
        <asp:BoundField DataField="Workgroup" HeaderText="Workgroup:" />
        <asp:BoundField DataField="Pathway" HeaderText="Pathway:" />
        <asp:TemplateField HeaderText="Nominal Completion:&nbsp;">
            <ItemTemplate>
                <asp:Label ID="labEndDate" runat="server" Text='<%# Eval("FinishDate","{0:d/MM/yyyy}") %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
    </Fields>
    <FooterTemplate>
        <asp:LinkButton ID="lbAddProgramUnits" runat="server" OnClick="AddProgramUnits_Click" ForeColor="White" Font-Bold="true"
            OnClientClick="return confirm('Import the Program Units listed - this may overwrite unit dates. Are you sure?');">Import from Program</asp:LinkButton>&nbsp;&nbsp;
        <a href="#" onclick="showhelp('progimphelp');" style="color:White;font-weight:bold;">Help</a>
    </FooterTemplate>
    <FooterStyle HorizontalAlign="Center" BackColor="LightSlateGray" />
</asp:DetailsView>

上記の Boundfields のいずれかの色が変わるたびにツールチップを表示できるようにしたいと考えています。

私の C# 分離コードには、データの特定の条件に応じてこれらのバインドされたフィールドの色を変更するコードがあります。これはうまくいっています。

しかし、私が望むのは、ユーザーがこれらの境界フィールドの上にマウスを置いたときに、そのフィールドの色が異なる場合にのみ、ユーザーにツールチップを提供できるようにすることです。

color.イエロー

.

4

2 に答える 2

3

そして、私自身の質問に答えるために、見落とされていた他の何かを見つけました.BoundFieldをTemplateFieldに変換するオプションです。

これから ...

<asp:BoundField HeaderText="Claim Type ID" ..etc../>

これに...

<asp:TemplateField HeaderText="Claim Type ID">
    <EditItemTemplate>
        <asp:Label ID="lblClaimTypeID" runat="server" Text='<%# Eval("ClaimTypeID") %>' ToolTip="Enter a numerical value that conforms to the UserChoice Policy document (ie: 65 for GAT)."></asp:Label>
    </EditItemTemplate>
    <InsertItemTemplate>
        <asp:TextBox ID="txtClaimTypeID" runat="server" Text='<%# Bind("ClaimTypeID") %>' ToolTip="Enter a numerical value that conforms to the UserChoice Policy document (ie: 65 for GAT)."></asp:TextBox>
    </InsertItemTemplate>
    <ItemTemplate>
        <asp:Label ID="itClaimTypeID" runat="server" Text='<%# Bind("ClaimTypeID") %>' ToolTip="A numerical value that conforms to the UserChoice Policy document (ie: 65 for GAT)."></asp:Label>
    </ItemTemplate>
</asp:TemplateField>

ASPX のデザイン モードでは、DetailsView を選択し、[フィールドの編集] オプションを選択して、BoundFields であるフィールドを選択し、直接 TemplateFields に変換できるため、これは便利です。その優れた点は、BoundFields をきちんとした Labels または TextBoxes に変換して、ToolTip プロパティで直接コーディングできるようにすることです! コードビハインドなし!マイクロソフトは、かつて何かを手に入れました。

于 2014-01-15T06:48:54.993 に答える