|
-
Apr 18th, 2003, 10:08 AM
#1
Thread Starter
Frenzied Member
datagrid [RESOLVED]
I am filling up a datagrid using a dataset on the page load event. The user is going to click on a row and I need the value of certain fields in that row. How can I get those values of the row they click on?
VB Code:
Dim cmdView As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter("select * from pcms.pcms_pcard_transaction_header ", objCon)
ds = New DataSet()
cmdView.Fill(ds, "cards")
dgView.DataSource = ds
dgView.DataMember = "cards"
Last edited by EyeTalion; Apr 22nd, 2003 at 07:44 AM.
It's tough being an unhandled exception...
___________
VB.NET 2008
VB.NET 2010
ORACLE 11g
CRYSTAL 11
-
Apr 18th, 2003, 01:13 PM
#2
Fanatic Member
Probably you want to examine DataGrid.CurrentRowIndex
ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfsystemwindowsformsdatagridclasscurrentrowindextopic.htm
...and maybe .CurrentCell
ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfsystemwindowsformsdatagridclasscurrentcelltopic.htm
Although I'm not 100% certain whether the CurrentRowIndex is of the table itself, or of the view in the DataGrid.
-
Apr 18th, 2003, 01:26 PM
#3
Thread Starter
Frenzied Member
can you paste the entire link...thanks
It's tough being an unhandled exception...
___________
VB.NET 2008
VB.NET 2010
ORACLE 11g
CRYSTAL 11
-
Apr 18th, 2003, 02:06 PM
#4
Fanatic Member
That is the entire link, if you have the environment help installed. Just stick that string into the Browser toolbar field in the dev environment. Or if you want to get it off of the online MSDN, you can go to:
http://msdn.microsoft.com/library/de...IndexTopic.asp
Gives you the same text, although once in a while there's an updated piece of info on the online version that obsoletes the local help.
-
Apr 21st, 2003, 08:52 AM
#5
Thread Starter
Frenzied Member
can someone convert this code, so I can use it in VB.NET. I'm getting an error becuse it's not a web control...
VB Code:
Private Sub dgView_EditCommand( _
ByVal source As Object, _
ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs _
) Handles dgView.EditCommand
Dim sFirstCell As String = e.Item.Cells(0).Text
Dim sSecondCell As String = e.Item.Cells(1).Text
' And so on...
End Sub
It's tough being an unhandled exception...
___________
VB.NET 2008
VB.NET 2010
ORACLE 11g
CRYSTAL 11
-
Apr 21st, 2003, 10:13 AM
#6
Fanatic Member
Doesn't look to me like there is a simple equivalent of DataGrid.EditCommand in Windows Forms. What behavior are you trying to get out of DataGrid?
-
Apr 21st, 2003, 12:11 PM
#7
Thread Starter
Frenzied Member
I need to know the value of the first cell of the row that was clicked
It's tough being an unhandled exception...
___________
VB.NET 2008
VB.NET 2010
ORACLE 11g
CRYSTAL 11
-
Apr 21st, 2003, 02:22 PM
#8
Fanatic Member
Then you probably want the DataGrid.CurrentCellChanged event.
ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfsystemwindowsformsdatagridclasscurrentcellchangedtopic.htm
e.g.:
Private Sub DataGrid1_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.CurrentCellChanged
Oh and as to:
Code:
Dim sFirstCell As String = e.Item.Cells(0).Text
Dim sSecondCell As String = e.Item.Cells(1).Text
based on:
ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfsystemwindowsformsdatagridclassitemtopic.htm
it would end up being (at least the way I would do it):
Code:
Dim sFirstCell As String = DataGrid1(DataGrid1.CurrentRowIndex, 0) 'cell 0
Dim sFirstCell As String = DataGrid1(DataGrid1.CurrentRowIndex, 1) 'cell 1
Last edited by Slow_Learner; Apr 21st, 2003 at 02:29 PM.
-
Apr 22nd, 2003, 07:43 AM
#9
Thread Starter
Frenzied Member
It's tough being an unhandled exception...
___________
VB.NET 2008
VB.NET 2010
ORACLE 11g
CRYSTAL 11
-
Apr 22nd, 2003, 09:21 AM
#10
Thread Starter
Frenzied Member
slow, another question...how do you change the names of the column headings?
It's tough being an unhandled exception...
___________
VB.NET 2008
VB.NET 2010
ORACLE 11g
CRYSTAL 11
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|