By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,168 Members | 2,511 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,168 IT Pros & Developers. It's quick & easy.

Reading DataGrid values directly

P: n/a
Hi:

I have a VB.NET web app that contains a datagrid on a web form that is
loaded as follows:

DataGrid1.DataSource = lookup.searchnames(getinformation)
DataGrid1.DataBind

The grid displays data for the user and contains one column that is an html
link.

In some circumstances I would like to be able to read the values in the
DataGrid - for example I may want to read the first row:

Logically:

dim myval as integer = Datagrid1.Row(0).Col(0).value

Does anyone know how to do this from a DataGrid?

Thanks very much!

Fred
Nov 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Private Sub DataGrid3_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles DataGrid3.MouseDown
Try
Dim myGrid As DataGrid = CType(sender, DataGrid)
Dim hti As System.Windows.Forms.DataGrid.HitTestInfo
hti = myGrid.HitTest(e.X, e.Y)
Select Case hti.Type
Case System.Windows.Forms.DataGrid.HitTestType.Cell
If (hti.Column = 0) Then
If Not (hti.Row < 0) Then
Dim intDealNumber As Integer = CInt(DataGrid3.Item(hti.Row, hti.Column))
End If
End If
End Select
Cursor = Cursors.Default
Catch ex As Exception
Cursor = Cursors.Default
WriteErrortoLog(ex, "DataGrid3 Mouse Down", "Main", 0)
blValidationFlag = False
End Try
End Sub

"Fred Nelson" wrote:
Hi:

I have a VB.NET web app that contains a datagrid on a web form that is
loaded as follows:

DataGrid1.DataSource = lookup.searchnames(getinformation)
DataGrid1.DataBind

The grid displays data for the user and contains one column that is an html
link.

In some circumstances I would like to be able to read the values in the
DataGrid - for example I may want to read the first row:

Logically:

dim myval as integer = Datagrid1.Row(0).Col(0).value

Does anyone know how to do this from a DataGrid?

Thanks very much!

Fred

Nov 20 '05 #2

P: n/a
Fred,

Resending a message with the same text has normally no sense, everybody
active on this newsgroup know it already and does not know the answer.

However I tried to answer you in your original question.

Cor
Nov 20 '05 #3

P: n/a
Brian:

Thanks for your help - I'm writing code for a vb.net web app and as such I
don't have any access to mouse events.

Can you answer this question (and I hope you can):

I have a datagrid that is loaded in a VB.NET web application. I need to
have my program extract information from the DataGrid directly in some
cases.

For example - I may need to obtain the first element from the first column
of the first row:

------- Logically:

dim myval as string

myval = datagrid1.col(0).row(0).item.value

-------

is there a way to do this - load myval from the first row, first column of
the datagrid?

Thansk again,

Fred

"BrianDH" <Br*****@discussions.microsoft.com> wrote in message
news:13**********************************@microsof t.com...
Private Sub DataGrid3_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles DataGrid3.MouseDown Try
Dim myGrid As DataGrid = CType(sender, DataGrid)
Dim hti As System.Windows.Forms.DataGrid.HitTestInfo
hti = myGrid.HitTest(e.X, e.Y)
Select Case hti.Type
Case System.Windows.Forms.DataGrid.HitTestType.Cell
If (hti.Column = 0) Then
If Not (hti.Row < 0) Then
Dim intDealNumber As Integer = CInt(DataGrid3.Item(hti.Row, hti.Column)) End If
End If
End Select
Cursor = Cursors.Default
Catch ex As Exception
Cursor = Cursors.Default
WriteErrortoLog(ex, "DataGrid3 Mouse Down", "Main", 0)
blValidationFlag = False
End Try
End Sub

"Fred Nelson" wrote:
Hi:

I have a VB.NET web app that contains a datagrid on a web form that is
loaded as follows:

DataGrid1.DataSource = lookup.searchnames(getinformation)
DataGrid1.DataBind

The grid displays data for the user and contains one column that is an html link.

In some circumstances I would like to be able to read the values in the
DataGrid - for example I may want to read the first row:

Logically:

dim myval as integer = Datagrid1.Row(0).Col(0).value

Does anyone know how to do this from a DataGrid?

Thanks very much!

Fred

Nov 20 '05 #4

P: n/a
Cor:

I know all about double postings!

I felt that I needed to post the question again as it was misunderstood by
the person who gave me a GREAT answer however the point that it was a web
app was missed.

If you check you will see that its asked differently.

Sorry for the confusion.

Fred

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:OK**************@TK2MSFTNGP11.phx.gbl...
Fred,

Resending a message with the same text has normally no sense, everybody
active on this newsgroup know it already and does not know the answer.

However I tried to answer you in your original question.

Cor

Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.