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
600
WebDataGrid - Evaluating fields inside of a TemplateDataField
posted

I have a WebDataGrid which has a column I've defined as a TemplateDataField.

In that field, I want to display data conditionally depending on the values of Field1 and Field 2

Field1 always has data, so I display it as follows:

<ig:TemplateDataField Key="ContactPersons">
<ItemTemplate>
  <%# DataBinder.Eval(CType(Container, Infragistics.Web.UI.TemplateContainer).DataItem, "Field1")%>
 </ItemTemplate>
</ig:TemplateDataField>

However, I first need to test the contents of Field2 to determine if I want to display it as well in that same column.

I'm wanting to use something similar to this:

<ig:TemplateDataField Key="ContactPersons">
 <ItemTemplate>
  <%# DataBinder.Eval(CType(Container, Infragistics.Web.UI.TemplateContainer).DataItem, "Field1")%>
  <%
       Dim strField2 As String
       strField2 = DataBinder.Eval(CType(Container, Infragistics.Web.UI.TemplateContainer).DataItem, "Field2")
       if strField2 <> "" then
             'Code for displaying Field2 here 
       end if
  %>
 </ItemTemplate>
</ig:TemplateDataField>

The strField2= line above does not work because that's the wrong syntax. 

My question is how do I retrieve data elements inside of an ItemTemplate so that I can evaluate them and add conditional logic?  How do I retrieve the value of Field2 so I can evaluate it?

strField2 = ????

Thanks,

John