5
Reply

How to bind data to gridview's textbox column

Riyaz Kalva

Riyaz Kalva

Feb 27 2013 4:24 AM
2.4k
Hi all.

I am new to windows application development.

I am using gridview that has all DataGridViewTextBoxColumn.

My code for binding the data to the grid view in Form_Load() is :

private void Form1_Load(object sender, EventArgs e)
  {
  cn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\\Bill\\dbBill.accdb");
  string query = "Select Sr,Desc,HSNCode,Qty,Rate,Qty*Rate as Amount from BillDetail";
  cn.Open();
  cmd = new OleDbCommand(query, cn);
  da = new OleDbDataAdapter(cmd);
  ds = new DataSet();
  da.Fill(ds);
  cn.Close();


  grdDetails.DataSource = ds;
  }
But I am not getting the records.

Please help.

Thanks in advance.

Attachment: bill.rar

Answers (5)