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;
}
else
{
l_blnWrite = false;
break;
}
}
if (!l_blnSavedRecord)
{
if(l_blnWrite)
ds.Tables[l_strTable].Rows.Add(myRow);
}
}