DropDownList Control Value

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bill Cart

    #1

    DropDownList Control Value

    In the MCAD/MSCD self paced training kit Chapter 5, the Contact application,
    there is a DropDownList box used to set the Contact Type. The book does not
    include instructions for setting up the drop down list but I looked at the
    code from the CD and I think it is set up correctly. With the code from the
    CD the ContactTypeID is always sets a value of 1 regardless of what the
    control is set to. It looks like it should work but it does not seem to. Any
    ideas?

    The datasource is called dsContactTypes and has a structure like:
    ContactTypeID ContactType
    1 Business
    2 Social
    3 Friend
    ..

    The dropdownlist is set:
    DataSource = dsContactTypes
    DataTextField = ContactType
    DataValueField = ContactTypeID


    The data is posted with:
    dsContacts.Cont actsRow rowNew;
    rowNew = dsContacts.Cont acts.NewContact sRow();
    ...
    rowNew.ContactT ypeID = convert.ToInt16 (drpContactType s.SelectedItem. Value);

    // Add the row to the data set.
    dsContacts.Cont acts.AddContact sRow(rowNew);
    try
    {
    // Modify the database.
    adptContacts.Up date(dsContacts );


Working...