ChaseWoofer
asked on
Dynamic Fields in ASP.NET (VB)
I have a table that I need to populate based off queries from a table on page load.
the ASPX page has the following table layout
In the code behind I have the following :
When the code runs, the control referenced by thisControl comes back with nothing.
the ASPX page has the following table layout
<table>
<tr>
<td><td>
<td colspan="4">Year 1</td>
<td colspan="4">Year 2</td>
<td colspan="4">Year 3</td>
</tr>
<tr>
<td><td>
<td>Q1</td>
<td>Q2</td>
<td>Q3</td>
<td>Q4</td>
<td>Q1</td>
<td>Q2</td>
<td>Q3</td>
<td>Q4</td>
<td>Q1</td>
<td>Q2</td>
<td>Q3</td>
<td>Q4</td>
</tr>
<tr>
<td>SALES</td>
<td><asp:Literal ID="Y1Q1" Text="" runat="server" /></td>
<td><asp:Literal ID="Y1Q2" Text="" runat="server" /></td>
<td><asp:Literal ID="Y1Q3" Text="" runat="server" /></td>
<td><asp:Literal ID="Y1Q4" Text="" runat="server" /></td>
<td><asp:Literal ID="Y2Q1" Text="" runat="server" /></td>
<td><asp:Literal ID="Y2Q2" Text="" runat="server" /></td>
<td><asp:Literal ID="Y2Q3" Text="" runat="server" /></td>
<td><asp:Literal ID="Y2Q4" Text="" runat="server" /></td>
<td><asp:Literal ID="Y3Q1" Text="" runat="server" /></td>
<td><asp:Literal ID="Y3Q2" Text="" runat="server" /></td>
<td><asp:Literal ID="Y3Q3" Text="" runat="server" /></td>
<td><asp:Literal ID="Y3Q4" Text="" runat="server" /></td>
</tr>
.................................................
The data is being pulled in the backend for each year/quarter.In the code behind I have the following :
Do While xYear < 4
Select Case xYear
Case Is = 1
thisYear = FirstYear.ToString
Case Is = 2
thisYear = SecondYear.ToString
Case Is = 3
thisYear = ThirdYear.ToString
End Select
Do While xQuarter < 5
Select Case xQuarter
Case Is = 1
thisQuarter = 1
Case Is = 2
thisQuarter = 2
Case Is = 3
thisQuarter = 3
Case Is = 4
thisQuarter = 4
End Select
'This does the query to get the data I will be working with.
myRecords = Library.GetLFNSTATS(thisYear + thisQuarter)
For Each row As DataRow In myRecords.Rows
thisField = "Y" & xYear & "Q" & xQuarter
thisControl = Me.FindControl(thisField)
thisControl.text = row("ColumnName").ToString.Trim
Next
xQuarter += 1
Loop
xYear += 1
Loop
When the code runs, the control referenced by thisControl comes back with nothing.
another example on the server side
tableID.Rows.Add(r)
tableID.Rows.Add(r)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
After much playing arround then going out and getting some fresh air, it came to me where I was doing the references for finding the control.
<asp:table id="tableID"
how does it know to return?