protected void NewManufacturerLink_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(NewManufacturerName.Value))
     {
         Manufacturer manufacturer = ManufacturerDataSource.LoadForName(NewManufacturerName.Value, true);
         ManufacturerList.DataBind();
         ListItem selectedItem = ManufacturerList.Items.FindByValue(manufacturer.Id.ToString());
         if (selectedItem != null)
         {
             ManufacturerList.SelectedIndex = ManufacturerList.Items.IndexOf(selectedItem);
         }
     }
 }
Esempio n. 2
0
 protected void AddManufacturerButton_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         Manufacturer manufacturer = ManufacturerDataSource.LoadForName(AddManufacturerName.Text, false);
         // MANUFACTURER NAME SHOULD BE UNIQUE
         if (manufacturer != null)
         {
             AddManufacturerNameRequired.IsValid      = false;
             AddManufacturerNameRequired.ErrorMessage = "The manufacturer with name \"" + AddManufacturerName.Text + "\" already exists.";
             return;
         }
         manufacturer      = new Manufacturer();
         manufacturer.Name = AddManufacturerName.Text;
         manufacturer.Save();
         AddManufacturerName.Text = String.Empty;
         AddedMessage.Text        = string.Format((string)ViewState["AddedMessage.Text"], manufacturer.Name);
         AddedMessage.Visible     = true;
         ManufacturerGrid.DataBind();
         SearchAjax.Update();
     }
 }