asp.nettooltipmouseoverdetailsviewboundfield

How to add a tooltip to Boundfields in a Detailsview, but only if color of column has changed


I have the following code ...

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

I want to be able to show a tooltip whenever one of the above Boundfields has changed color.

In my C# codebehind, I have code that changes the color of these boundfields depending on certain conditions of the data. This is working fine.

But what I want is to be able to give the users a tooltip when ever they hover their mouse over these Boundfields and ONLY if that field is coloured differently, in my case

color.Yellow

.


Solution

  • If you are setting the color to yellow in the DetailsView DataBound event based on some criteria, you can set the tooltip in that same block:

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