in

dashCommerce

An ASP.NET Open Source e-Commerce Application

Retrieving from dropdown list

Last post 06-30-2008 10:46 PM by yitzchok. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 06-30-2008 11:34 AM

    • sbck
    • Top 200 Contributor
    • Joined on 06-06-2008
    • Posts 4

    Retrieving from dropdown list

    I have a dropdown list containing the manufacturers and it is being loaded like this:

       private void LoadManufacturer () {
          ManufacturerCollection manufacturerCollection = new ManufacturerController().FetchAll();
          manufacturerCollection.OrderByAsc(Manufacturer.Columns.Name);
          ddlManufacturer.DataSource = manufacturerCollection;
          ddlManufacturer.DataTextField = Manufacturer.Columns.Name;
          ddlManufacturer.DataValueField = Manufacturer.Columns.ManufacturerId;
          ddlManufacturer.DataBind();
        }

     

    After the user selects the Manufacturer and clicks on a button,  I need to programmatically get the CreatedBy value from the selected Manufacturer and store it in a string.  I know it is in the Manufacturer object within the ManufacturerCollection that the list is bound to but I have no idea how to access it.  Can anyone give me an example of how to get the value?

    Thanks! 

     

     

  • 06-30-2008 10:46 PM In reply to

    Re: Retrieving from dropdown list

    First you would get the data like this.

       private void LoadManufacturer () {
          ManufacturerCollection manufacturerCollection = new ManufacturerCollection();
          manufacturerCollection.OrderByAsc(Manufacturer.Columns.Name).Load();//The OrderByAsc has to called before you get the items from the DB
    ...
    ...

        }

    (I think the only way you can access it is if you store it in the ViewState or SessionState)
    But what I think you should do is something like this
    Manufacturer manufacturer = new Manufacturer(ddlManufacturer.SelectedItem.Value);//This will get the info from the DB

    Find a bug? Create a Work Item for a fast response.. Want to help? Create a patch for us!
Page 1 of 1 (2 items)