Practice Final Answers -- Winter 09

Part A. 

1. See the section Applying CSS Classes to Asp.Net Controls in the
   6/1 Lecture Notes for parts a, b, and c.  Here is the event handler
   for part d:

   public void btnShowLen_Click(object sender, EventArgs e)
   {
       txtLength.Text = txtInput.Text.Length;
   }

2. Event handler:

   public void btnSubmit_Click(object sender, EventArgs e)
   {
       txtTeam.Text = Table1.Rows[2].Cells[1].ToString( );
       foreach (TableCell c in Table1.Rows[3])
           txtDisplay.Text += c.ToString( );
       StreamWriter sw = new StreamWriter(c:\Database\myteam.txt);
       sw.WriteLine(Table1.Rows[1].Cells[0].ToString( ));
   }

3. a. Change the type of the button to type=submit.
      Change the form tag to
      <form name=frmSeedOrder action=record-order.aspx method=get>

   b. Change the line
      string sql = INSERT INTO Orders VALUES ('Peas', 5, 3.45);;
      to the lines

      string seedType = Request.Params[txtSeedType];
      int quantity = int.Parse(Request.Params[txtQuantity]);
      double price = double.Parse(Request.Params[txtPrice]);
      string sql = INSERT INTO Orders VALUES ( +
          ' + seedType + ', + quantity + , + price );;
      litSql.Text = sql;

4. string sql = SELECT * FROM Mascots WHERE  +
      Team = ' + txtTeam.Text;

   litMascot.Text = ds.Tables[0].Rows[0].ItemArray[1].ToString( );