470,619 Members | 1,469 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,619 developers. It's quick & easy.

Hidden data addition

Hello,

I was wondering if anyone could tell me a good way to add data to a datagrid
(or it's dataset) when the user edits/adds a record in a datagrid.

Basically, I want to be able to add a username / timestamp to a record, I'm
sure there are plenty of ways to do this, but I'm sure it's been done before
and was wondering if anyone had any good proceedures they use, since I've
started using datagrids more frequently.

Thanks In Advance,
Eric Dreksler
Nov 20 '05 #1
3 845
Hi Eric,

When we are talking about data processing than the starndaard datasource of
a datagrid is/are datatable(s). (Can by using the dataview however it stays
the datatable)

You can add as much datacolumns to a datatable as you wish however than you
should use the datagridtablestyles to show the proper colums in the
datagrid.

You can as well declare the datatable withevents which means that you can by
instance use the datatable row changed event to do updating as you say.

Just some idea's

Cor

I was wondering if anyone could tell me a good way to add data to a datagrid (or it's dataset) when the user edits/adds a record in a datagrid.

Basically, I want to be able to add a username / timestamp to a record, I'm sure there are plenty of ways to do this, but I'm sure it's been done before and was wondering if anyone had any good proceedures they use, since I've
started using datagrids more frequently.

Thanks In Advance,
Eric Dreksler

Nov 20 '05 #2
All right,
I have my datagrid setup (and I'm using a DataTable), however I can't seem
to figure out how to get the RowChanging and RowChanged events to work for
me.

On RowChanging, it won't let me change a row marked for updating. And on
RowChanged, if I try to update the e.Row arguement it sends me into a loop
(continually calling the RowChanged Event), until it just crashes out.
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:e7**************@TK2MSFTNGP12.phx.gbl...
Hi Eric,

When we are talking about data processing than the starndaard datasource of a datagrid is/are datatable(s). (Can by using the dataview however it stays the datatable)

You can add as much datacolumns to a datatable as you wish however than you should use the datagridtablestyles to show the proper colums in the
datagrid.

You can as well declare the datatable withevents which means that you can by instance use the datatable row changed event to do updating as you say.

Just some idea's

Cor

I was wondering if anyone could tell me a good way to add data to a

datagrid
(or it's dataset) when the user edits/adds a record in a datagrid.

Basically, I want to be able to add a username / timestamp to a record,

I'm
sure there are plenty of ways to do this, but I'm sure it's been done

before
and was wondering if anyone had any good proceedures they use, since I've started using datagrids more frequently.

Thanks In Advance,
Eric Dreksler


Nov 20 '05 #3
Hi Eric,

I thought something as this (however I am not very sure, the endedit did
throw an error, but it was not needed for this sample, it is more said in
this newsgroup, that this event is not the best part of the framework)

However, I hope it helps?

Cor

\\\
Dim bool As Boolean
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
'to make the sample table
dt.Columns.Add("col1")
dt.Columns.Add("col2")
For i As Integer = 0 To 5
Dim dr As DataRow = dt.NewRow
dr(0) = i.ToString
dt.Rows.Add(dr)
Next
DataGrid1.DataSource = dt
bool = True
End Sub

Private Sub dt_RowChanged(ByVal sender As Object, _
ByVal e As System.Data.DataRowChangeEventArgs) _
Handles dt.RowChanged
e.Row.BeginEdit()
If bool Then
e.Row(1) = e.Row(0)
End If
End Sub
///
Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Eduard Dewolf | last post: by
351 posts views Thread by CBFalconer | last post: by
2 posts views Thread by Bill Steele | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.