Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: DataGridView
The following exception occured in the DataGridView:
System.ArgumentException: DataGridViewComboBoxCell Value is not valid.
To replace this default dialog please handle the DataError Event.
 

i have a datagridview and in datagridview two fill combobox from database but when i select combobox value in second row the above following error occured...in c# windows application....
and plz ans send me my email address..
 
my email is msv.svm@gmail.com
 
so plz help me...
 
private void sample_Load(object sender, EventArgs e)
{
 

SqlCommand cmd = new SqlCommand("Select CatID, CatName from CategoryMaster", cnn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(dt);
 
Column1.DataSource = dt;
Column1.DisplayMember = "CatName";
Column1.ValueMember = "CatID";

}
 
private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 0)
{

string catID = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
 
SqlCommand cmd1 = new SqlCommand(@"SELECT ProdID, ProdName FROM ProductMaster WHERE CatID ='" + catID + "' ", cnn);
SqlDataAdapter da1 = new SqlDataAdapter(cmd1);
DataSet ds1 = new DataSet();
dt1.Clear();
da1.Fill(dt1);
 
dataGridView1.Rows[e.RowIndex].ErrorText = String.Empty;
Column2.DataSource = dt1;
Column2.DisplayMember = "ProdName";
Column2.ValueMember = "ProdID";

}
}
Posted 30-Jun-13 19:38pm
Edited 30-Jun-13 20:18pm
v2
Comments
Sergey Alexandrovich Kryukov at 1-Jul-13 2:15am
   
In what line of code? You should provide reasonably comprehensive code sample...
—SA
Mangukiya Shailesh at 1-Jul-13 2:22am
   
i update my question with sample code
Sergey Alexandrovich Kryukov at 1-Jul-13 2:29am
   
OK, but comment the line where the exception is thrown. Also, please wrap the code in "pre" tags (with the attribute lang="cs").
—SA
Mangukiya Shailesh at 1-Jul-13 2:34am
   
in this code have a no error but when at run time in datagridview first row is perfect work...but in second row, category name is select and then when product select the error is occured...
Mangukiya Shailesh at 1-Jul-13 2:35am
   
means product name is no select more than one row...means only one product is select in multiple row...
Mangukiya Shailesh at 1-Jul-13 6:20am
   
i solved my problem

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

  Print Answers RSS
0 OriginalGriff 310
1 Sergey Alexandrovich Kryukov 176
2 PhilLenoir 164
3 Magic Wonder 162
4 Gihan Liyanage 119
0 Sergey Alexandrovich Kryukov 6,140
1 OriginalGriff 5,195
2 CPallini 2,473
3 Richard MacCutchan 1,607
4 Abhinav S 1,505


Advertise | Privacy | Mobile
Web03 | 2.8.140814.1 | Last Updated 1 Jul 2013
Copyright © CodeProject, 1999-2014
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