Click here to Skip to main content
15,896,912 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hello All,
Am working on the Window form application and I am using "DataGrideView" Control On that.I have tabcontrols on that and my both the tab consist 2 diffrerent "DataGrideView" I use the code below to fill "DataGrideView" on my first tab and its working absolutly fine:

C#
 con.Open();
OleDbCommand cmdcop = new OleDbCommand("Select * from Rechcop", con);
if (cmdcop.ExecuteReader().HasRows)
{
    OleDbDataAdapter adpcop = new OleDbDataAdapter("Select * from Rechcop", con);
    DataTable dtcop = new DataTable();
    adpcop.Fill(dtcop);
    grdRich.DataSource = dtcop;
    con.Close();
}
else
{
    MessageBox.Show("No Recharg Coupan is added yet.Add RechargeCoupan.");
    tabControl1.Focus();
}

But when I want to fill DataGrideView on second tab with same method but datagridview is different the code below is executes but still DataGridview is Empty.
C#
con.Open();
OleDbCommand cmdsim = new OleDbCommand("Select * from SimCard", con);
if (cmd.ExecuteReader().HasRows)
{
    OleDbDataAdapter adpsim = new OleDbDataAdapter("Select * from SimCard", con);
    DataTable dtsim = new DataTable();
    adpsim.Fill(dtsim);
    grdSimCard.DataSource = dtsim;
    con.Close();
}
else
{
    MessageBox.Show("No SimCard is added yet.Add SimCard.");
    tabControl1.Focus();
}


I tried to refersh the DataGride but it wont work,also I try to populate that on ButtonClick enevt still it wont help.

Can sombody Help me to tackle that issue....?

Thanks in Advance
Yogesh
:-)
Posted
Updated 10-Jun-12 2:08am
v4
Comments
VJ Reddy 10-Jun-12 8:07am    
Edit: pre tag for C# code added.

1 solution

add the gridviewname.bind() in your application..
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900