Hi.
iam using system.data.oledb;
//My code is
OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\db1.mdb"); //try //{aConnection.Open();
string strsql = "select * from ParentDetails"; OleDbCommand aCommand = new OleDbCommand(strsql, aConnection); OleDbDataAdapter da = new OleDbDataAdapter(aCommand); DataSet ds = new DataSet();da.Fill(ds);
dataGridView1.DataSource = ds;
dataGridView1.bi //Here Iam not getting the daraGridview 1.DataBind();
aConnection.Close();
so tell me how to bind the data is there an y other syntax
Kirtan PatelPosted Apr 18, 2009, 9:40 AM
and if you want to Bind Your Grid View Values to TextBoxes
then
You Can use CurrencyManager
for example u have 2 Fields in Grid "username and password " then u could use like
declare CurrencyManager and DataSet as Globle
/*********************************
CurrencyManager cmgr ;
DataSet ds;
OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\db1.mdb");
//try
//{
aConnection.Open();
string strsql = "select * from ParentDetails";
OleDbCommand aCommand = new OleDbCommand(strsql, aConnection);
OleDbDataAdapter da = new OleDbDataAdapter(aCommand);
ds = new DataSet();
da.Fill(ds);
dataGridView1.DataSource = ds;
aConnection.Close();
cmgr = (CurrencyManager)this.BindindContext[ds.Tables[0]];
/********************** Code For Binding textBoxes **************** /
textBox1.DataBindings.Clear();
textBox2.DataBindings.Clear();
textBox1.DataBindings.Add("Text", ds.Tables[0],"Username");
textBox2.DataBindings.Add("Text", ds.Tables[0],"Password");
Happy Coding :)
Happy Coding :)