Click here to Skip to main content
11,929,505 members (55,986 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# .NETCF C#4.0
I am working with a windows app and have a form that contains a datagridview that has bound and unbound controls. My dropdowns have 2 parts - item and the value. (A = some value1; B = some value2, and so on). Item = A;B... Value = some value1; some value2.....

The user sees this in the dropdown - "some value1"

The value going into the subtable is: "A = somevalue1"

I need to enter Item "A" into the database table, but am having difficulty grabbing it.

The text fields load to the database fine. How do I get the correct value from the datagridview dropdowns?

I currently have:
for (int i = 0; i < dataGridView1.Rows.Count; i++)
    for (int j = 0; j < dataGridView1.Columns.Count; j++)
        if ((dataGridView1.Rows[i].Cells[j].Value != null) &&
             (dataGridView1.Rows[i].Cells[j].Value.ToString().Trim() != ""))
            myRow[dataGridView1.Columns[j].Name.Trim()] = dataGridView1.Rows[i].Cells[j].Value.ToString().Trim();
            l_blnWrite = true;
            l_blnWrite = false;
    if (!l_blnSavedRecord)
Posted 27-Mar-13 5:26am
Edited 27-Mar-13 6:26am
YAIR-I 27-Mar-13 12:56pm
The dropdowns are columns in the datagrid view?

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Yes, there are a combination of field types that are columns, Text and combo boxes.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web04 | 2.8.151126.1 | Last Updated 27 Mar 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100