Hello Sir,
I am creating windows application c# 2010, here i am explain my project details any one solve my problem sir.
I am using 2 two drop down list
i am select first drop down list that time values are dispaly on my data grid view with some empty rows.
check my
image link[
^] sir.
-------------------------------------------------------------------
After that i am select 2nd drop down list
that time i want records update on my empty row cells.
this is my
second image link[
^] sir,
But not fixed for 3rd and 4th rows are empty, some times 6th, 7th and 8th rows are empty.
How to create my logic sir, give me some help sir,
What I have tried:
How to bind values on data grid view empty cells using c# windows forms
Edit - OP code from a comment
is is my code, i am write this code my 2nd comboBox SelectedIndexChanged Event
SqlConnection con1 = new SqlConnection(db.Connectionstring());
con1.Open();
using (SqlCommand cmd1 = new SqlCommand("select * from pardetails where parname='" + comcredeb.Text + "'", con1))
{
using (SqlDataReader dr1= cmd1.ExecuteReader())
{
cmd1.CommandType = CommandType.Text;
using (SqlDataAdapter sda = new SqlDataAdapter(cmd1))
{
using (DataSet ds1 = new DataSet())
{
if (dr1.HasRows)
{
bool Empty = true;
foreach (DataGridViewRow row in dataGridView1.Rows)
{
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
while (dr1.Read())
{
Empty = true;
for (int j = 0; j < dataGridView1.Columns.Count; j++)
{
if (dataGridView1.Rows[i].Cells[1].Value != null && dataGridView1.Rows[i].Cells[1].Value.ToString() != "")
{
Empty = false;
break;
}
}
if (Empty)
{
row.Cells[1].Value = dr1.GetString(19);
row.Cells[1].Value = dr1.GetString(21);
}
}
}
}
dr1.Close();
con1.Close();
sda.Fill(ds1);
}
}
}
}
}
dataGridView1.Focus();
}