[thelist] ASP.NET: adding controls to a placeholder

Robert Vreeland vreeland at studioframework.com
Fri Sep 22 06:43:38 CDT 2006


You would add the dropdown list it to the TableCell.Controls collection
before you add the TableCell to the TableRow.Controls collection, before you
add...
Just layout your for each loop to build each element in order. 
Maybe this will help, this is the code I used to generate a websafe color's
table on the fly
If you have any questions, feel free to email me off list.
{
	TableRow R = new TableRow();
	TableCell C = new TableCell();
	
	TableRow thisRow = new TableRow();
	TableCell thisCell = new TableCell();
	Table thisTable = new Table();
	string[] hexadecimalColorArray = {"FF", "CC", "99", "66", "33",
"00"};
	int iRowGroups ;
	int iRow = 6;
	int iCell = 6;
	for(iRowGroups=0;iRowGroups<=2;iRowGroups++){
		thisTable = new Table();
		for(iRow=0;iRow<=5;iRow++){
			R = new TableRow();
			for(iCell=0;iCell<=5;iCell++){
				
				string cellColor =
hexadecimalColorArray[iRowGroups] +
hexadecimalColorArray[iRow] + hexadecimalColorArray[iCell];
				C = new TableCell();
				Panel cellPanel = new Panel();
				cellPanel.Style.Add("border", " 2px outset
#" + cellColor );
				cellPanel.Style.Add("background-color", "
#"+ cellColor);
				cellPanel.Style.Add("width", " 20px");
				cellPanel.Style.Add("height", " 12px");
				cellPanel.Attributes.Add("onmousedown",
"updatecolorChoice('#" + cellColor + "')");
				C.Controls.Add(cellPanel);
				R.Controls.Add(C);
			}
		thisTable.Controls.Add(R);
		}
		thisCell = new TableCell();
		thisCell.Controls.Add(thisTable);
		thisRow.Controls.Add(thisCell);
	}
	
	ColorTable.Controls.Add(thisRow);
	thisRow = new TableRow();
	for(iRowGroups=3;iRowGroups<=5;iRowGroups++){
		thisTable = new Table();
		for(iRow=0;iRow<=5;iRow++){
			R = new TableRow();
			for(iCell=0;iCell<=5;iCell++){
				
				string cellColor =
hexadecimalColorArray[iRowGroups] + hexadecimalColorArray[iRow] +
hexadecimalColorArray[iCell];
				C = new TableCell();
				Panel cellPanel = new Panel();
				cellPanel.Style.Add("border", " 2px outset
#" + cellColor );
				cellPanel.Style.Add("background-color", "
#"+ cellColor);
				cellPanel.Style.Add("width", " 20px");
				cellPanel.Style.Add("height", " 12px");
				cellPanel.Attributes.Add("onmousedown",
"updatecolorChoice('#" + cellColor + "')");
				C.Controls.Add(cellPanel);
				R.Controls.Add(C);
			}
		/*ColorTable.Controls.Add(R);*/
		thisTable.Controls.Add(R);
		}
		thisCell = new TableCell();
		thisCell.Controls.Add(thisTable);
		
		thisRow.Controls.Add(thisCell);
	}
	DateTime myDate =  DateTime.Now;
	string mydate;
	mydate = myDate.ToString("d");
	
	ColorTable.Controls.Add(thisRow);
	copyNotice.Text="&copy; 2002 - " + mydate + " All rights reserverd.
StudioFramework.com";		
	
	
		
	
		
		
} 


Sincerely,
Robert Vreeland
Managing Partner 
StudioFramework 
-----Original Message-----
From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org] On Behalf Of Casey Crookston
Sent: Thursday, September 21, 2006 4:48 PM
To: thelist at lists.evolt.org
Subject: [thelist] ASP.NET: adding controls to a placeholder

We're building a page that ask a questions about products (shirts) being
returned to a manufacturer. First, the user is asked, "How many items will
be returned."  Based on the number they enter into the textbox, x, we need
to now repeat this code x times:

 

<table>

  <tr>

    <td>Size:</td>

    <td><asp: dropdown id="drpSizex" runat="server" /></td>

    <td>color: </td>

    <td><asp: dropdown id="drpColorx" runat="server" /></td>

  </tr>

</table>

 

Then we need to populate each dropdown with data from the database (this I
should be able to handle).  The part I can't figure out is how to repeat
that set of code x times.  Of course a simple for next loop would do the
repeating part.  I've created a place holder on the page.  I can add the
html (<table> etc...) with literal controls, and I can even add the
dropdowns.  But... how do I add the dropdowns at just the right location?
(inside the <td>'s)

 

Am I overlooking something obvious?

 

Casey

 

-- 

* * Please support the community that supports you.  * *
http://evolt.org/help_support_evolt/

For unsubscribe and other options, including the Tip Harvester and archives
of thelist go to: http://lists.evolt.org Workers of the Web, evolt ! 




More information about the thelist mailing list