Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1910
Display link if column is a certain value...and plain text if column is a different value
posted

I have a field "Claim_Nbr" that I want to display as a hyperlink if another field "Show_as_Link" = "Y", but I just want it displayed as plain text if the field "Show_as_Link" = "N". Here is what I want, but it's not working...

IF Eval("Chow_as_Link") = "Y" THEN
 <ig:TemplateDataField Key="CLAIM_NBR">
  <ItemTemplate>
          <asp:HyperLink ID="link" runat="server" NavigateUrl='<%# "File.aspx?Claim_ID=" & Eval("Claim_Nbr") %>' Text='<%# Eval("Claim_Nbr")%>' ></asp:HyperLink>
  </ItemTemplate>
  <Header Text="Claim #" />
 </ig:TemplateDataField>
ELSE
 <ig:BoundDataField DataFieldName="Claim_Nbr" Key="Claim_Nbr">
 <Header Text="Claim #" />
 </ig:BoundDataField>
END IF

Parents
No Data
Reply
  • 29417
    Suggested Answer
    Offline posted

    Hello algunderson ,

     

    Thank you for posting in our forum.

     

    You cannot change the column type  based on the value in a specific row.

    You could specify the field as a bound one and set for it the HtmlEncode property to "false". This will allow you to enter html in for the cell’s text and that value won’t be encoded.

    For example:

     <ig:BoundDataField DataFieldName="Claim_Nbr" Key="Claim_Nbr" HtmlEncode="false">

     <Header Text="Claim #" />

     </ig:BoundDataField>

     

    Then in the InitializeRow event you could get the cell from the column “Show_as_Link” and if the value is “Y” then change the text of the cell from column “Claim_Nbr” to contain a link element. For example:

      if (e.Row.Items.FindItemByKey("Show_as_Link").Value == "Y")

            {

            e.Row.Items.FindItemByKey("Claim_Nbr").Text="<a>"+e.Row.Items.FindItemByKey("Claim_Nbr").Text+"</a>;

            }

     

    Let me know if you have any questions or concerns.

     

    Best Regards,

    Maya Kirova

    Developer Support Engineer II

    Infragistics, Inc.

    http://ko.infragistics.com/support

     

Children
No Data