Link to home
Start Free TrialLog in
Avatar of arunkotte
arunkotte

asked on

Datagrid row clears off upon moving to a new row

Hi,
  I have been struggling with this problem from yesterday. I have a datagrid. I am changing the text on the remaining columns of a row based on a value selected in a dropdown(the dropdown is in the first column). The changed values are displayed fine. But when i change the row. i.e, select the next row on the grid, the values in the row previously added dissappear. Can anyone help me how to retain the changed values even after changing the row. What am i doing wrong. I have the following code sample where i am adding the values.
Thank you
 

Dim s As String
Dim rs As New ADODB.Recordset

str = "Select * from KobeList where [ID Number]='" + Trim(Me.grdTable.Columns(0).Text) + "'"
rs.Open str, g_con, adOpenStatic, adLockOptimistic, adCmdText
If Not rs.EOF Then

Me.grdTable.Columns(2).Value = rs("ID Number")
Me.grdTable.Columns(3).Value = rs("MT2000")

End If


Avatar of vinnyd79
vinnyd79

Is the Datagrid bound to another recordset?
Avatar of arunkotte

ASKER

No the datagrid is not bound to any Recordset.  I populate the Datagrid using Additem.
call datagrid1.update()

additionallt, it looks like you are trying to change the values in the grid, but are using a datatable or something to hold the data.  Try changing the data in the datatable before changing the data in the grid.



TRUENEUTRAL,
   I have called Me.grdTable.Update and now that is where the items in columns are getting cleared up.
Have you tried changing the data in the underlying datatable first?
2 possibities I come across before like this ... Just look will it be the below mistake

1.Constraints which force to clear when other datatype data entered
2.When any RowFilter is used and when the filter key value itself changed , the row will get cleared ...

Regards,
Nagarajan S

TRUENEUTRAL
   I am not using recorsets to display the data. I tried updating the data into the target table in the beforeUpdate function. But even that din`t stop it from clearing the row.

Mr. Nagarajan

    I am using a string data type all the way through. So no question of entering a different data type
  Nor, I am using any RowFilter.

I am in desperate need of help here.
Thank you
 
check the properties of datagrid. AllowAddNew,AllowUPdate,AllowDelete. AllowAddnew and AllowUpdate must be false in your case. It will be solved.
write me back if problem continues... with some exact details of what you are doing.
please provide a more comprehensive example of your code (like how you fill the datagrid)
Because I just checked VB6 documentation and cannot find additem in the methods of Datagrid
Thank you very much for your time , But i have switched to ADODC and it works for me now.
Thank you
The Problem is not solved. You can go ahead and clean it up but please refund my points.

Thank you
I would like you to note that twice I asked you to try modifying the data in the underlying datatable.

I also asked for a comprehensive example.

I feel that your problem has remained unsolved since you were unwilling to try the solution, and unwilling to provide additional information.

We are here voluntarily to try and hep you, but you must first be willing to help yourself.
arunkotte,

You had ignored the suggestions of the experts that were trying to help you. That's why my recommendation remains "NO refund".

Venabili
ASKER CERTIFIED SOLUTION
Avatar of ee_ai_construct
ee_ai_construct
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial