i am not sure check this one
foreach (DataGridViewRow Datarow in dataGridView1.Rows)
{
if (dataGridView1.RowCount == Datarow.Index +1)
{
if (Datarow.Cells[0].Value != null && Datarow.Cells[1].Value != null && Datarow.Cells[2].Value != null)
{
WhereClause += Datarow.Cells[0].Value.ToString() + " " + Datarow.Cells[1].Value.ToString() + " " + Datarow.Cells[2].Value.ToString() + " ";
SearchQuery = WhereClause;
}
else
{
MessageBox.Show("Must Fill Column-کالم لازمی پر کریں", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
else
{
if (Datarow.Cells[0].Value != null && Datarow.Cells[1].Value != null && Datarow.Cells[2].Value != null && Datarow.Cells[3].Value != null)
{
WhereClause += Datarow.Cells[0].Value.ToString() + " " + Datarow.Cells[1].Value.ToString() + " " + Datarow.Cells[2].Value.ToString() + " " + Datarow.Cells[3].Value.ToString() + " ";
}
else
{
MessageBox.Show("Must Fill Column-کالم لازمی پر کریں", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
tell me if it work or not