Combo box with foreign key in Datagrid

Discussion in 'ASP .Net Datagrid Control' started by Rob Edwards, Oct 22, 2003.

  1. Rob Edwards

    Rob Edwards Guest

    Two tables: Employee, Salary

    I want to be able to update the Salary information with the dates and
    changes to each employee in a datagrid.

    The EmployeeID is the foreign key in the Salary table.

    OK... so I created a datagrid with the datasource being the Salary table.
    I converted the EmployeeID column into a template column.
    The datasource of that column is the employee table
    The DataTextField is the name of the employee
    The DataValueField is the EmployeeID

    In DataBindings I have bound the SelectedValue to the EmployeeID in the
    Salary table.

    I fill the data adapter in:

    If not Page.IsPostBack
    daSalary.Fill(DsSalary1)
    daEmployee.fill(DsEmployee1)

    The problem is the same name is displayed in each of the rows (that being
    the value of the first row returned).

    How do you return the different SelectedValue for each row in the datagrid?

    Thanks.
    Rob Edwards, Oct 22, 2003
    #1
    1. Advertising

  2. Hi Rob,

    I am sorry if there is any misunderstanding but I am not sure about the
    exact meaning of "How do you return the different SelectedValue for each
    row in the datagrid?". Please clarify it more detailed.

    In addition, I have found some related articles regarding this issue for
    your reference.

    Creating Custom Columns for the ASP.NET Datagrid
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html
    /creatingcustomcolumns.asp
    "...
    Next I need to convert this sample over to use a live table from the
    database. ShipVia is a foreign key to the lookup table "Shippers," which
    I'll assign as the DataSource to our DropDownColumn in the code..."

    Managing Hierarchical Inserts in ASP.NET and ADO.NET
    http://msdn.microsoft.com/msdnmag/issues/03/07/DataPoints/
    "...
    The key ingredient in building hierarchical applications is to create
    related DataTable objects within a DataSet. This sample application relies
    on the relationship between the orders and their order detail records for
    displaying the values and for updating the values to the database. To
    establish this symbiosis, a DataRelation object is created and set up to
    link the orders DataTable and the order details DataTable. If a relation is
    created on a field that is already a foreign key to the same parent table,
    the relation will use the existing foreign key..."

    I hope it helps.

    Best regards,

    Jacob Yang
    Microsoft Online Partner Support
    Get Secure! ┬ĘC www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.
    Jacob Yang [MSFT], Oct 23, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hicks
    Replies:
    0
    Views:
    804
    Hicks
    Jun 9, 2004
  2. H5N1
    Replies:
    0
    Views:
    436
  3. Lionel
    Replies:
    9
    Views:
    3,392
  4. dthmtlgod

    Fill Combo Box based on another Combo Box

    dthmtlgod, Nov 16, 2005, in forum: ASP General
    Replies:
    1
    Views:
    586
    Bob Barrows [MVP]
    Nov 16, 2005
  5. SM
    Replies:
    2
    Views:
    364
Loading...

Share This Page