K
kvg sasi
Guest
Hi all,
Good Day! I am using C# in Visual Studio 2008. I want to display the data of a single table into single datagridview but different conditions.
And my code is below. Please help me to solve this problem.
for (int i = 0; i < 9; i++) // 9 tab pages
{
ID = Convert.ToInt32(Math.Pow(2, i));
cmd = new SqlCommand("Select fldMmsg from tmessage_temp where fldTo=" + ID + "", cn);
cmd.CommandType = CommandType.Text;
switch (ID)
{
case 1:
SqlDataAdapter sdr = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sdr.Fill(dt);
rdr = cmd.ExecuteReader();
while (rdr.Read())
{
//dataGridView1.Columns[0].Name = "fldMmsg";
//dataGridView1.Columns[0].HeaderText = "fldMmsg";
//dataGridView1.Columns[0].DataPropertyName = "fldMmsg";
dataGridView1.DataSource = dt;
dataGridView1.Refresh();
}
MessageBox.Show("one");
rdr.Close();
break;
case 2:
SqlDataAdapter sdr1 = new SqlDataAdapter(cmd);
DataTable dt1 = new DataTable();
sdr1.Fill(dt1);
rdr = cmd.ExecuteReader();
while (rdr.Read())
{
dataGridView1.DataSource = dt1;
//dataGridView1.Refresh();
}
rdr.Close();
break;
}
}
Thanks & Regards Sasi ................. Go Green
Continue reading...
Good Day! I am using C# in Visual Studio 2008. I want to display the data of a single table into single datagridview but different conditions.
And my code is below. Please help me to solve this problem.
for (int i = 0; i < 9; i++) // 9 tab pages
{
ID = Convert.ToInt32(Math.Pow(2, i));
cmd = new SqlCommand("Select fldMmsg from tmessage_temp where fldTo=" + ID + "", cn);
cmd.CommandType = CommandType.Text;
switch (ID)
{
case 1:
SqlDataAdapter sdr = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sdr.Fill(dt);
rdr = cmd.ExecuteReader();
while (rdr.Read())
{
//dataGridView1.Columns[0].Name = "fldMmsg";
//dataGridView1.Columns[0].HeaderText = "fldMmsg";
//dataGridView1.Columns[0].DataPropertyName = "fldMmsg";
dataGridView1.DataSource = dt;
dataGridView1.Refresh();
}
MessageBox.Show("one");
rdr.Close();
break;
case 2:
SqlDataAdapter sdr1 = new SqlDataAdapter(cmd);
DataTable dt1 = new DataTable();
sdr1.Fill(dt1);
rdr = cmd.ExecuteReader();
while (rdr.Read())
{
dataGridView1.DataSource = dt1;
//dataGridView1.Refresh();
}
rdr.Close();
break;
}
}
Thanks & Regards Sasi ................. Go Green
Continue reading...