-
December 29th, 2008, 02:41 AM
#1
Datagridview not editing
HI
IN MY VB.NET 2005 APPLICATION, I placed one datagridview conntrol.
This control is filled from from a table(single table involved) using datatable and dataadapter.
I want to edit the the data in the grid and and pass changes to the table direclty.
user can change data in the gird but not get reflected the changes in the database.
I even tried even MSDN sample code for filling the datagridview, but still not working
any idea
VB.Net 2005, Net Framework 2.0
-
December 29th, 2008, 02:49 AM
#2
Re: Datagridview not editing
Post the error, and code of what you've tried. It's easier to bind controls than not, but you can also NOT update a record. It depends on what you've done so far...
-
December 29th, 2008, 03:39 AM
#3
Re: Datagridview not editing
using the following code I initialise my grid
gird is filled, I want user to edit the columns, could add new rows, delete exisiting one.
Grid is editable, but not reflected into the database
Dim dt1 As New DataTable, adptr1 As New SqlDataAdapter ' declared at class objects
Private Sub InitializeDataGridView()
Try
' Set up the DataGridView.
With Me.DataGridView2
' Automatically generate the DataGridView columns.
.AutoGenerateColumns = True
cmdobj.CommandType = CommandType.Text
cmdobj.CommandText = "select * fromauthors"
adptr1.SelectCommand = cmdobj : adptr1.Fill(dt1)
BindingSource1.DataSource = dt1
DataGridView2.DataSource = BindingSource1 '.Tab
' Automatically resize the visible rows.
.AutoSizeRowsMode = _
DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders
' Set the DataGridView control's border.
.BorderStyle = BorderStyle.Fixed3D
' Put the cells in edit mode when user enters them.
.EditMode = DataGridViewEditMode.EditOnEnter
End With
Catch ex As SqlException
MessageBox.Show(ex.Tomessage)
System.Threading.Thread.CurrentThread.Abort()
End Try
End Sub
VB.Net 2005, Net Framework 2.0
-
December 29th, 2008, 07:19 PM
#4
Re: Datagridview not editing
This should do it:
Code:
DataGridView2.DataSource = String.Empty
-
December 30th, 2008, 02:23 AM
#5
Re: Datagridview not editing
Dear lienna
where to set this property?, string.empty
kindly give me a tutorial, the mechanism of editing and reflecting to
underlying tables of datagridview
VB.Net 2005, Net Framework 2.0
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|