Code to set the tables
Expand|Select|Wrap|Line Numbers
- protected void LoadCityStateControl(int origin, int destination)
- {
- //initializing the origin city/state controls
- Table city = new Table();
- city.ID = "tblcity";
- city.BorderStyle = BorderStyle.Solid;
- city.BorderWidth = 1;
- for (int i = 0; i < origin; i++)
- {
- TableRow tr = new TableRow();
- TableCell tc = new TableCell();
- tc.ID = "tc" + (i + 1);
- Label mx = new Label();
- mx.Text = "Origin City/State #" + (i + 1) + " : ";
- mx.ID = "lblorgcitystate" + (i + 1);
- TextBox tx = new TextBox();
- tx.ID = "txtOrgCityState" + (i + 1);
- Label mn = new Label();
- mn.ID = "lbltest" + (i + 1);
- mn.Text = " (eg: Cape Girardeau,MO )";
- tc.Controls.Add(mx);
- tc.Controls.Add(tx);
- tc.Controls.Add(mn);
- tr.Cells.Add(tc);
- city.Rows.Add(tr);
- }
- cpanel.Controls.Add(city);
- //initializing the destination city/state controls
- Table descity = new Table();
- descity.ID = "tbldescity";
- descity.BorderStyle = BorderStyle.Solid;
- descity.BorderWidth = 1;
- for (int i = 0; i < destination; i++)
- {
- TableRow trd = new TableRow();
- TableCell tcd = new TableCell();
- tcd.ID = "tcd" + (i + 1);
- Label mxd = new Label();
- mxd.Text = "Destination City/State #" + (i + 1) + " : ";
- mxd.ID = "lbldestcitystate" + (i + 1);
- TextBox txd = new TextBox();
- txd.ID = "txtDestCityState" + (i + 1);
- Label mnd = new Label();
- mnd.ID = "lbldtest" + (i + 1);
- mnd.Text = " (eg: Dallas,TX )";
- tcd.Controls.Add(mxd);
- tcd.Controls.Add(txd);
- tcd.Controls.Add(mnd);
- trd.Cells.Add(tcd);
- descity.Rows.Add(trd);
- }
- cpanel.Controls.Add(descity);
- }
Expand|Select|Wrap|Line Numbers
- int orgcounter = Int32.Parse(txtNumPicks.Text);
- int descounter = Int32.Parse(txtNumDrops.Text);
- for (int i = 0; i <= orgcounter; i++)
- {
- foreach (Control c in cpanel.Controls)
- {
- Table m = (Table)c.FindControl("tbldescity");
- foreach (TableRow r in m.Rows)
- {
- foreach (TableCell tc in r.Cells)
- {
- orgcity = ((TextBox)tc.FindControl("txtOrgCityState" + (i).ToString())).Text;
- }
- }
- }
- }
Expand|Select|Wrap|Line Numbers
- lblerr.Text = c.Controls.Count.ToString();