How to check that... datagridview Row or Rows is/are empty
if datagridview row is empty then error must be show.
User can't leave datagridview until insert all the data in it.
Plz... tell me what's the coding for that.
I already had 2 rows on form Page Load....
The user fill only one row, and click on "Save" button without filling the second row...
in that time,
after saving... the system must be check that all rows are filled well..
if not...
it shows...MessageBox
"Please fill complete information"
Loading

Kiresh Gangariya52 reputationPosted Jun 3, 2013, 2:15 AM EDT
change row count to graterthan 1
if(GridView2.Items.Count() > 1){
//your code
}
Nilesh Dalvi36 reputationPosted Jun 3, 2013, 2:26 AM EDT
The user fill only one row, and click on "Save" button without filling the second row...
in that time,
after saving... the system must be check that all rows are filled well..
if not...
it shows...MessageBox
"Please fill complete information"
Sunny SharmaRank #223 · 11.1K reputationPosted Jun 3, 2013, 2:44 AM EDT
How about checking for every cell in all the rows:
----------------------------
foreach (DataGridViewRow dr in DGV1.Rows)
{
foreach (DataGridViewCell dc in dr.Cells)
{
if (dc.Value == "")
{
// Show Message; return;
}
}
}
----------------------------
Hope it helps.
Mark it as answer if it helps.
Thanks.
Pankaj PandeyRank #642 · 3.7K reputationPosted Jun 3, 2013, 3:01 AM EDT
try it..
VulpesRank #55 · 29.2K reputationPosted Jun 3, 2013, 3:07 AM EDT
So, I'd replace this line:
if (dc.Value == "")
with this one:
if (dc.Value == null || dc.Value.ToString().Trim() == "")
Sunny SharmaRank #223 · 11.1K reputationPosted Jun 3, 2013, 3:10 AM EDT