[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 197
  • Last Modified:

Need to change datagrid cell values programatically

On the Mouse Up event, I ask the user if they want to automatically update the values in this row.  If they say yes, I want to change various cell values and display those changes in the grid.
I assume I have to change the table and refresh the grid.  I am not getting any errors but I don't see the updates in the grid.  My dataset contains 3 tables.  The last one is the one bound to the datagrid.  Here is my code.

If Result = DialogResult.Yes Then
                Dim intRow As Integer = DataGrid1.CurrentRowIndex
                DsReqUpd14.Tables(2).Rows(intRow)(2) = Date.Today.ToString()
                DataGrid1.Refresh()
 End If
0
RuthD2004
Asked:
RuthD2004
2 Solutions
 
kGeniusCommented:
Your code doesn't accept the changes.

This should be your code (I thought, haven't checked it)

If Result = DialogResult.Yes Then
                Dim intRow As Integer = DataGrid1.CurrentRowIndex
                DsReqUpd14.Tables(2).Rows(intRow)(2) = Date.Today.ToString()
               
                'AcceptChanges, accept the changes !!
                DsReqUpd14.AcceptChanges()
               
                DataGrid1.Refresh()
 End If

Hope it 'll help
kGenius
0
 
eozz_2000Commented:
Or you can do this:

me.DataGrid1.Item(me.DataGrid1.CurrentRowIndex, here_the_number_of_the_column)

in here_the_number_of_the_column you can put the column number of the columns that you want to change its value:

me.DataGrid1.Item(me.DataGrid1.CurrentRowIndex, 0) = "Hello"
me.DataGrid1.Item(me.DataGrid1.CurrentRowIndex, 1) = "Bye"

in this code you will put the values "Hello" and "Bye" in the cell that you wanted, and then you can update your table.
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now