Click here to Skip to main content
15,891,939 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
foreach (DataGridViewRow row in LanguageGridView.Rows)
              {                  
                  for (int i = 0; i < LanguageGridView.Rows.Count; i++)
                  {
                                        
                          string selectedLanguage;
                          selectedLanguage = LanguageGridView.Columns[2].HeaderText;
                          string id = row.DataGridView.Rows[i].Cells["GID"].Value.ToString().Trim();
                          string name = row.DataGridView.Rows[i].Cells[2].Value.ToString();
                        //  LanguageGridView.AutoGenerateColumns = false;    
                          if (id!=null && name.Trim() == null)
                          {
                              continue;
                          }
                     

                          _localizationBusinessService.UpdateColumn(selectedLanguage, name, id);
                     
                  }
Posted
Updated 3-Oct-13 19:45pm
v2
Comments
Member 10314566 4-Oct-13 1:27am    
please tell me how to solve
Ron Beyer 4-Oct-13 1:46am    
How about you tell us what line its on, simply pasting a code dump does not help us find the error, you need to tell us what line and exactly what variable is giving the error. We can't see your screen or access your computer, and we can't reproduce your program with the little bit you gave, so help us help you and tell us where you get the error.

1 solution

What are you trying to do?
You have an outer loop which runs through each row, then an inner loop which also runs through each row in the same grid. Inside the inner loop, you use the row from the outer loop to get the grid it is part of and then use the value from the inner loop to access every row in the grid. You then do a test which will always fail (because AA string.Trim call will never return null) before calling an update method.

So if you have 100 rows, you will call the update method 10,000 times...

Rather than suggesting a solution to the specific problem you have, I would recommend that you take a good, hard look at this code (and anything else that looks like it) and rethink your design...
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900