473,414 Members | 1,598 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Reading DataGrid values directly

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
4 10590
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Angel | last post by:
Is it possible to update a datagrid directly without having to use the underlying datatable? I use framework 1.0. Angel
6
by: ALI-R | last post by:
Hi All; I'm reading the following xml file into a Dataset but there are only 4 datatables in my dataset (which should be 5) Is that because I have two nodes with the same name (detail) in my xml...
24
by: Mike L | last post by:
This is for a Win form, in C# 2005. I want to load a datagrid, make some columns width 0, and then clean out the record I added. I get the error message, ""Index was out of range. Must be...
7
by: Stephen | last post by:
Hi I need to set up a table or datagrid where the user is able to input values directly into the cells. What i am attempting to build is a page that displays all the days of the year with the...
5
by: Hennie | last post by:
When trying to update a record in an editable datagrid I ran into a few problems. My update procedure is just not working. Can someone please have a look at my code and see what am I doing wrong....
5
by: Coleen | last post by:
Hi all :-) We are using a DB2 database connection through a class module to get the data into a datagrid in an aspx web page using VB.Net. I can get the data into the first datagrid with no...
3
by: Fred Nelson | last post by:
Hi: I have a VB.NET web app and in one section I'm creating a datagrid that lists several id's and names - I would like to be able to send the user to another web page if only one record matches...
4
by: Ty | last post by:
Hi all Short version of my problem: i have a Datagrid (Flexgrid from ComponentOne) with a Datatable as source. I need to search a row in the datatable, using a primary key column in the...
8
by: Brock | last post by:
I am trying to populate a Crystal Report from data in my DataGrid. The reason for this is that I want the user to be able to change values without updating the database, but still have their report...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.