Presenting an autopopulated dropdown list in a formview populated by a gridview RRS feed

  • Question

  • User-20784283 posted

    Dear Community,

    A GridView displays the content of a table stored in an Access database.
    Documents can be edited with a FormView when Edit button is pressed.
    A field (many in the future) in this FormView should be choosen between entries from a second table.

    If tried this :
    - create a new AccessDataSource pointing to this second table
    - add a dropdown list pointing using the new AccessDataSource.
    => Got a runtime error : No value given for one or more required parameters

    I do not have any idea about this error as no text in the error message is refering to any known component.

    So my question : could this be achieved ? If yes, what am I missing ?

    Thanks a lot for any suggestion.


    Tuesday, October 9, 2012 3:28 PM

All replies

  • User2013247590 posted

    make sure the datatextfield and datavaluefield is set on dropdownlist


    also set  SelectedValue to select their current choice like so

    SelectedValue ='<%# Bind("DDLId") %>'

    Tuesday, October 9, 2012 4:52 PM
  • User-20784283 posted

    Not sure to understand what has to be done.

    Here is the error:

    Line 172:                <asp:DropDownList ID="DropDownList1" runat="server"
    Line 173:                    DataSourceID="AccessDataSource3" DataTextField="Libelle"
    Line 174:                    DataValueField="Libelle" SelectedValue='<%# Bind("Libelle") %>'>

    HttpException (0x80004005): DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'Libelle'.]

    Under DropDownList Tasks

    Under Configure Data Source:

    Datafield to display : "Libelle" (field I want to display a list)
    Datafield for the value : "LIbelle"

    Under Edit Data Bindings:

    SelectedValue = Bind("Libelle")

    Should these 3 values refer to different objects ?

    Thanks a lot !

    Wednesday, October 10, 2012 2:15 PM
  • User2013247590 posted

    the error is stating that field is not in your query result - does not contain a property with the name 'Libelle'

    what does the datasource and query look like?

    Wednesday, October 10, 2012 2:44 PM
  • User-20784283 posted


    Datasource : Database4.accdb ---it's an Access db

    SELECT * FROM [OperationType] ORDER BY [Libelle]  --- "OperationType" is the table from which I want to present a list in which user will choose a value to fill in another field (in this context also named "OperationType" in the table "Mvt"

    I left the SelectedValue property empty and buid the project.
    No more runtime error and the list displayed in the DropDownList control is correct.
    My understanding of th problem is growing, but I still miss two important things.

    1. The first choice displayed is not the one stored (if any) in the current record: I should present the current value as default
      =>DataFieldText ?
    2. Once a choice has been made and the Update button hit, the new value should be recorded
      =>DataFieldValue ?

    Am I right ?

    Thanks for your help.

    Wednesday, October 10, 2012 3:09 PM
  • User2013247590 posted

    you will need to put the SelectedValue back in to do the update

    it will crash if the value cannot match one from the lookup table OperationType

    AppendDataBoundItems = true; will let you set up one empty record with a default value of empty string then if your record is blank it will match up to the default record like                              

    <asp:ListItem Text="Choose Libelle" Value="" />


    Wednesday, October 10, 2012 4:20 PM
  • User-20784283 posted

    Ok: got it for "Choose libelle" entry.

    But I am still missing how I have to set the dropdownlist to present the current field content as default.
    Maybe it is not possible ?
    Do I have to display the field (coming from MVT table) and to present the dropdownlist (populated with table OPERATIONTYPE) as an additionnal field used to choose a new value from ?

    Friday, October 12, 2012 3:37 PM