Click here to Skip to main content
16,010,022 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a DataGridView with few column cells. all i want is to check an empty cells and write null by default. if some of the columns are not filled., i want a default null text to the specific cells that are committed

I tried to create something like this but it is not working as i don't know how i can take it further

C#
if (Gridview_Output.Rows.Count > 0)
            {

                foreach (DataRow dr in oDataSet.Tables[0].Rows)
                {

                    string _Car = dr[1].ToString();
                    string _Dealer = dr[2].ToString();
                    string _Model = dr[4].ToString();

                    if (_Car.Length == 0)
                    {
                        _Car = "NULL";
                    }

                    if (_Dealer.Length == 0)
                    {
                        _Dealer = "NULL";
                    }

                    if (_Model.Length == 0)
                    {
                        _Model = "NULL";
                    }
                }

            }
Posted
Updated 5-Mar-15 22:02pm
v3
Comments
Peter Leow 6-Mar-15 3:30am    
GridView or DataGridView?
Bacanzela 6-Mar-15 4:02am    
Datagridview

1 solution

 
Share this answer
 
v3
Comments
Bacanzela 6-Mar-15 3:30am    
am using winforms

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