2013-12-18 16 views
3

I가 다음 코드 ...방법은 DetailsView에 Boundfields에 툴팁을 추가 할 수 있지만, 컬럼의 색상이 변경된 경우에만

<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# 코드 숨김에서 데이터의 특정 조건에 따라이 바운드 필드의 색을 변경하는 코드가 있습니다. 이것은 잘 작동합니다.

는하지만 내가 원하는 것은 그들이이 Boundfields 위로 마우스를 가져가 그 필드가 color.Yellow

내 경우

에, 다른 색깔의 경우에만 그 어느 때 사용자에게 툴팁을 줄 수있을 것입니다

.

답변

1

당신은 몇 가지 기준에 따라 위해 DetailsView DataBound 이벤트에 노란색 색상을 설정하는 경우, 당신은 같은 블록에 툴팁을 설정할 수 있습니다

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

감사합니다. 그렇게 간단한 것. 나는 그 재산에 대해 몰랐다. – Fandango68

+0

나는 이것이 오래된 게시물 인 것을 알고 있지만, CSS 팁을 CSS 팁에 추가하는 방법이있다. – JustLearning

+2

@CosmosBanda는 사이트를 검색하거나 별도로 질문한다. 우리는 코멘트에 관련없는 질문에 대답하지 않는다. 다른 질문입니다. – ethorn10

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를 깔끔한 레이블 또는 텍스트 상자로 변환하여 툴팁 속성에 직접 코드를 작성할 수 있다는 것입니다. 그리고 뒤에 코드! Microsoft는 한 번만 뭔가를 얻었습니다.