Accessing data in a datagrid...

Please support our VB.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Thread Solved
Reply

Join Date: Jun 2008
Posts: 2
Reputation: phantom715 is an unknown quantity at this point 
Solved Threads: 0
phantom715 phantom715 is offline Offline
Newbie Poster

Accessing data in a datagrid...

 
0
  #1
Jun 2nd, 2008
I have a basic program that access a local Access database, reads data from it into a datagrid, and then allows me to manipulate it by using textboxes. I can add, delete, and search for records. I want to remove the textboxes from the equation completely. Is there any way I can access the data in the datagrid through code so I can use it in SQL statements?

i.e. DataGrid.SelectedRow.Column(3).Value
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,640
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: Accessing data in a datagrid...

 
3
  #2
Jun 2nd, 2008
initial condition
  1. Dim i As Integer
  2. i = dgUser.CurrentRowIndex()

i.e : (this following code will select user where id user = value of first column from selected datagrid). Of course in datagrid click event :
  1. Private Sub dgPendidikan_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgPendidikan.Click
  2. ...
  3. cmdUser.CommandText = "SELECT * FROM Users where IdUser ='" & Trim(dgUser.Item(i, 0)) & "'"
  4. ....
  5. end sub
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 2
Reputation: phantom715 is an unknown quantity at this point 
Solved Threads: 0
phantom715 phantom715 is offline Offline
Newbie Poster

Re: Accessing data in a datagrid...

 
0
  #3
Jun 2nd, 2008
Thank you so much! I am teaching myself databases, and was stuck on this for days. I thought I tried everything, but I guess not. Thanks!
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,640
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: Accessing data in a datagrid...

 
0
  #4
Jun 2nd, 2008
you're Welcome
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC