Check empty datagridview columns

I have a datagridview in my Form which contains some data. Actually what i want is on click of the button, if datagridview contains any column which contains nothing means it is empty or null then it should show message like "Datagridview column can't be null."
Posted by Harpreet 3/23/2014 6:06:16 PM
Total Answers : 2
Answer 1
try this way :
 for (int i = 0; i <= dataGridView1.Rows.Count - 1; i++)
{
if (Convert.IsDBNull(dataGridView1.Rows[0].Cells[i].Value))
{
//your code here if null
}
else
{
//your code here if not null
}
}


Is this what you want ?
Posted by StepCoder Team 3/25/2014 1:32:30 PM
Answer 2
Use the loop to check for empty columns.
 for (int i = 0; i <= dataGridView1.Rows.Count - 1; i++)
{
if (Convert.IsDBNull(dataGridView1.Rows[0].Cells[i].Value))
{
//your code here if null
}
else
{
//your code here if not null
}
}
Posted by Andrew Dvorkin 3/26/2014 5:17:04 PM
Post your answer
Preview
Sign in to your account
Your Email : 
Password :   
Forgot your password
Don't have StepCoder account ?
Create a new account
 
Follow me on twitter
About Me
Harpreet Singh
I began programming with C++ when i was 17. Then at the middle of my study .NET came. Then I began to read C# and VB.NET. By the time i learnt SQL and ASP.NET, and developed some websites such as news portals that are active now. Currently i am running my own Software company.
Answer these questions! If you know the answer.