We help IT Professionals succeed at work.

Datagrid row clears off upon moving to a new row

arunkotte
arunkotte asked
on
325 Views
Last Modified: 2010-04-17
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


Comment
Watch Question

Commented:
Is the Datagrid bound to another recordset?

Author

Commented:
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.


Author

Commented:

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?

Commented:
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

Author

Commented:
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.

Author

Commented:
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

Author

Commented:
Thank you very much for your time , But i have switched to ADODC and it works for me now.
Thank you

Author

Commented:
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.

Commented:
arunkotte,

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

Venabili
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.