Asp.net 如何向Detailsview中的Boundfields添加工具提示,但仅当列的颜色已更改时

Asp.net 如何向Detailsview中的Boundfields添加工具提示,但仅当列的颜色已更改时,asp.net,tooltip,mouseover,detailsview,boundfield,Asp.net,Tooltip,Mouseover,Detailsview,Boundfield,我有以下代码 <asp:DetailsView ID="dvApprenticeship" runat="server" DataSourceID="dsApprenticeship" AutoGenerateRows="false" BackColor="#E0E8F0" GridLines="None" CellPadding="2" DataKeyNames="ProgramID, ProgramName, OrganisationName, StudyYearID, Wor

我有以下代码

<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>

我想能够显示一个工具提示,每当上述边界字段之一已改变颜色

在我的C#codebehind中,我有一些代码,可以根据数据的某些条件更改这些边界字段的颜色。这很好用

但我想要的是,当用户将鼠标悬停在这些边界字段上时,并且仅当该字段的颜色不同时(在我的例子中),才能为用户提供工具提示

颜色,黄色


.

如果根据某些条件在DetailsView
数据绑定事件中将颜色设置为黄色,则可以在同一块中设置工具提示:

DetailsViewRow.Cells[indexofyellowfield].ToolTip = "some help from code-behind";

为了回答我自己的问题,我还发现了一些被忽略的东西:convert BoundField to 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,选择Edit Fields(编辑字段)选项,选择BoundFields(边界字段)字段,并将其直接转换为TemplateFields(模板字段)。其美妙之处在于,它将边界字段转换为整洁的标签或文本框,允许您直接在工具提示属性中编码!而且没有代码隐藏!微软这一次得到了一些东西。

谢谢!这么简单的事情。我不知道这个属性。我知道这是一篇老帖子,但有没有办法在工具提示中添加css,@CosmosBanda搜索网站或单独提问……我们不会在对不同问题的回答的评论中回答不相关的问题。