I have the following table row in my .aspx page:
<tr> <td valign="bottom" style="width: 157px">Initial Requirements: </td> <asp:Repeater ID="Repeater11" runat="server" DataSourceID="ObjectDataSource1"> <ItemTemplate> <td valign="bottom" id="ReqStatus" runat="server" style="background-color: Gray"> <%#ReqStatus(CType(CType(Container.DataItem, System.Data.DataRowView).Row, DataSet1.DataTable1Row))%> </td> </ItemTemplate> </asp:Repeater> </tr>
In the code behind, I have this function:
Protected Function ReqStatus(ByVal Project As DataSet1.DataTable1Row) As String 'Dim ReqTableCell As TableCell 'ReqTableCell = form1.FindControl("ReqStatus") ' Check the status of the Development Completed Dim rightNow As Date = Now() Dim dateDifference As TimeSpan If Not Project.IsNull("Requirements_Target") Then Dim ReqTargetDate As Date = Project.Requirements_Target If Project.IsNull("Req_Date") Then dateDifference = ReqTargetDate.Subtract(rightNow) If dateDifference.Days > 0 Then If dateDifference.Days >= 60 Then 'ReqTableCell.BackColor = Drawing.Color.Green Return "<strong><font color='green'>" & dateDifference.Days & "</font></strong>" ElseIf dateDifference.Days > 30 And dateDifference.Days < 60 Then 'ReqTableCell.BackColor = Drawing.Color.Yellow Return "<strong><font color='yellow'>" & dateDifference.Days & "</font></strong>" Else 'ReqTableCell.BackColor = Drawing.Color.Red Return "<strong><font color='red'>" & dateDifference.Days & "</font></strong>" End If Else 'ReqTableCell.BackColor = Drawing.Color.Red Dim pastDue As Int16 = (dateDifference.Days * -1) Return "<strong><font color='red'>" & pastDue & "</font></strong> days past" End If End If Else End If End Function
I can change the color of the return value based on conditional statements, but I canβt determine the correct syntax for changing the table cell database. My attempt is commented out.
How to declare a table cell? Findcontrol should not be the right way.
source share