Reading DataGrid values directly

F

Fred Nelson

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
 
G

Guest

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
 
C

Cor Ligthert

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
 
F

Fred Nelson

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 said:
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))
 
F

Fred Nelson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top