Ejemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         // Populate the GridView
         FleetGrid.DataSource = Fleet;
         FleetGrid.DataBind();
     }
 }
Ejemplo n.º 2
0
        protected void ClearForm_Click(object sender, EventArgs e)
        {
            Registry.Text           = string.Empty;
            ShipClass.SelectedIndex = 0;
            Fleet.Clear();
            // Populate the GridView
            FleetGrid.DataSource = Fleet;
            FleetGrid.DataBind();

            MessageLabel.Text = "Fleet Scrapped.";
        }
Ejemplo n.º 3
0
        protected void AddShip_Click(object sender, EventArgs e)
        {
            // Get the data from the form & put it into a new Ship object
            Ship theShip = new Ship();

            theShip.RegistryId = Registry.Text;           // for the TextBox
            theShip.Class      = ShipClass.SelectedValue; // for the Drop-Down
            theShip.Power      = int.Parse(Power.Text);   // for the TextBox range control (converted to int)
            Fleet.Add(theShip);
            // Populate the GridView
            FleetGrid.DataSource = Fleet;
            FleetGrid.DataBind();

            MessageLabel.Text = "Ship Added";
        }