GridView Add row

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2008
Posts: 75
Reputation: mansi sharma is an unknown quantity at this point 
Solved Threads: 0
mansi sharma mansi sharma is offline Offline
Junior Poster in Training

GridView Add row

 
0
  #1
33 Days Ago
I have bind the DataGridview with DB. To add the data from textboxes to DataGrid, I use the foll. code-

  1. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  2. Try
  3. Dim row0 As String() = {TextBox1.Text, TextBox2.Text, TextBox3.Text}
  4. DataGridView1.Rows.Add(row0)
  5. row0 = Nothing
  6. Catch ex As Exception
  7. MsgBox(ex.Message)
  8. End Try
  9. End Sub




Error is coming
Rows cannot be programmatically added to the DataGridView's rows collection when the control is data-bound

there is no any way to add data to the Gridview if we bound it to the Database.
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 289
Reputation: TomW is on a distinguished road 
Solved Threads: 38
TomW TomW is offline Offline
Posting Whiz in Training
 
0
  #2
32 Days Ago
The DataGridView control is simply a means of displaying data from an underlying datasource such as a DataSet/DataTable/Array etc.... You do not want to add rows directly to the DataGridView, you want to add rows to the underlying datasource. Such as if you have a datatable attached, it is the datatable you want to add a row too.
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC