473,378 Members | 1,104 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,378 software developers and data experts.

Row/Cell of Datagrid - Still need help! (Please?)

I've been trying since last Friday to get an answer on how to get a SPECIFIC row.cell value from a datagrid. I've had plenty of suggestions, but nothing works to get the value from a SPECIFIC Row and cell. Right now I have this code

Sub Item_Bound(ByVal sender As Object, ByVal e As DataGridItemEventArgs
lbl_test.Text = lbl_test.Text & " " & e.Item.ItemInde
Session("wa_tot_gal") = e.Item.Cells(7).Tex
Response.Write(Session("wa_tot_gal")
End Su

it returns
1¢ Amount (NRS 373.030)000000000000000120

this information is from every row (including the header) I need the specific information for the value 12 returned to me so I can use that value as a session variable that needs to populate another web page table. I can NOT get it to return the SPECIFIC Row data! Please, can someone help me? Thanks much, Coleen
---
Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest Community Website: http://www.dotnetjunkies.com/newsgroups/
Nov 20 '05 #1
21 2320
Dim ROW as Int32=1

Dim COL as Int32=1

MessageBox.Show(dgPeople.Item(ROW ,COL).ToString())
OHM

coleenholley wrote:
I've been trying since last Friday to get an answer on how to get a
SPECIFIC row.cell value from a datagrid. I've had plenty of
suggestions, but nothing works to get the value from a SPECIFIC Row
and cell. Right now I have this code:

Sub Item_Bound(ByVal sender As Object, ByVal e As
DataGridItemEventArgs) lbl_test.Text = lbl_test.Text & " " &
e.Item.ItemIndex Session("wa_tot_gal") = e.Item.Cells(7).Text
Response.Write(Session("wa_tot_gal"))
End Sub

it returns:
1¢ Amount (NRS 373.030)000000000000000120

this information is from every row (including the header) I need the
specific information for the value 12 returned to me so I can use
that value as a session variable that needs to populate another web
page table. I can NOT get it to return the SPECIFIC Row data!
Please, can someone help me? Thanks much, Coleen.
---
Posted using Wimdows.net NntpNews Component - Posted from .NET's
Largest Community Website: http://www.dotnetjunkies.com/newsgroups/


--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com
Nov 20 '05 #2
Cor
Hi Coleen,

I tested that code I did send you.

And that is not the code I see now.

Did it not work?

Cor
Nov 20 '05 #3
Thanks OHM, however it does not work. I tried:

Response.Write(dtg_worksheet1.Item(ROW, COL).ToString())

I can't use a messagebox in the ASPX VB code-behind, so I tired a Response.write - I get an error "Item is not a member of System.Web.UI.WebControls.DataGrid" - so I tried:

Response.Write(dtg_worksheet1.Items(ROW).ToString) - which gives me a compliation error "Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index" Any other suggestions?

---
Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest Community Website: http://www.dotnetjunkies.com/newsgroups/
Nov 20 '05 #4
Hi Cor - Thanks, but no, it didn't. I can get the column, or the cell, but I NEED the specific row and cell value. What I really don't undertand, is why does it work perfectly in an ASP.Net table and yet there is no function for a datagrid to return the value of a specific Row().Cell()? Even if you don't know exactly how many rows are going to be returned, you should be able to get a specific Row/Cell value from a datagrid! I've read everything in the Help files I can find, tried all the suggestions and CAN'T get the specific Row/cell value I need. Any help is GREATLY appreciated. Thanks :-)

---
Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest Community Website: http://www.dotnetjunkies.com/newsgroups/
Nov 20 '05 #5
thr ROW and COL are just my variables, replace them with actual variables or
a number and try it. The messagebox was just a suggestion


coleenholley wrote:
Thanks OHM, however it does not work. I tried:

Response.Write(dtg_worksheet1.Item(ROW, COL).ToString())

I can't use a messagebox in the ASPX VB code-behind, so I tired a
Response.write - I get an error "Item is not a member of
System.Web.UI.WebControls.DataGrid" - so I tried:

Response.Write(dtg_worksheet1.Items(ROW).ToString) - which gives me a
compliation error "Index was out of range. Must be non-negative and
less than the size of the collection. Parameter name: index" Any
other suggestions?

---
Posted using Wimdows.net NntpNews Component - Posted from .NET's
Largest Community Website: http://www.dotnetjunkies.com/newsgroups/


--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com
Nov 20 '05 #6
Sorry, on my last post, I didn't put that I tried that..

Response.Write(dtg_worksheet1.Item(16, 7).ToString()) - I get an error (Blue Squigleys) that "Item is not a member of System Web.UI.WebControls.Datagrid. I tried using Items instead of Item, but still get an error "Too many arguments to Public.OVerloads ReadOnly Default propert Item(Index as Integer) as System Web.Ui.WebControls.DataGrid" Any suggestion on why I am getting these errors? Do I need to Import another System Namespace? Thanks for your help. COleen

---
Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest Community Website: http://www.dotnetjunkies.com/newsgroups/
Nov 20 '05 #7
Sorry Cor, I did not get your post from my other thread until just now. I tried your code and get this error:

Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
This is the code I tried:

Dim a As String = dtg_worksheet1.Items(16).Cells(7).Text
Session("wa_tot_gal") = a
Response.Write(Session("wa_tot_gal"))
I've been remming one suggestion, trying another, and trying the help file suggestion of:
Dim X As String
X = e.Item.Cells(7).Text.IndexOf(16).ToString
Response.Write(X) - This returns me -1-1-1-1-1-1-1-1-1....

Thanks for all of your help :-)

---
Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest Community Website: http://www.dotnetjunkies.com/newsgroups/
Nov 20 '05 #8
Cor
Are you sure you tested this code and it did not work, I did test it on a
webform datagrid and it did give me back the information from the row and
the cell from the datagrid.

When clicked
Dim a As String = grd.Items(e.Item.ItemIndex).Cells(3).Text

or as you ask

Dim a as string = grd.Items(15).Cells(6).Text

And i got a row (Items) and a Cell value, I real do not understan why this
is not working with you.

Cor

Hi Cor - Thanks, but no, it didn't. I can get the column, or the cell,

but I NEED the specific row and cell value. What I really don't undertand,
is why does it work perfectly in an ASP.Net table and yet there is no
function for a datagrid to return the value of a specific Row().Cell()?
Even if you don't know exactly how many rows are going to be returned, you
should be able to get a specific Row/Cell value from a datagrid! I've read
everything in the Help files I can find, tried all the suggestions and CAN'T
get the specific Row/cell value I need. Any help is GREATLY appreciated.
Thanks :-)
Nov 20 '05 #9
Cor
Hi Colleen,

The 16th row is 15 because it starts on 0
The 7th cel is 6 because it starts on 0,

That was also in my sample.

Cor

Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

Nov 20 '05 #10
Umm, are you saying that once the datagrid is populated, you click the row/cell and get the value? The trouble with that is that our users are not going to be clicking on this cell. I need the value to be passed automatically, without any intervention from the user.

The datagrid is read only, and is not always even going to be viewed. In other words, the user may choose not to view this page, but I must do a redirect to pass the session variable whether the user views the page or not, and the user is not going to know that the particular value needs to be clicked - it all needs to take place behind the scenes...

Thanks I will try it again, and see if I get values when the cell is clicked, then maybe I can devise a way to pass the value without clicking... I really do appreciate all of your help :-)

---
Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest Community Website: http://www.dotnetjunkies.com/newsgroups/
Nov 20 '05 #11
Yes, I know that the datagrid is 0 based - I have started at 0 counted over 7 columns and counted down 16 rows. I created an Excel Spreadsheet to space out the data so I could tell which row/cell the data I need would land in..

I just ran the program again with this exact code
Dim a As String = dtg_worksheet1.Items(16).Cells(7).Text - and I get this message

Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

The program builds ok with no errors, but won't complie becasue of that message..

I don't know why it doesn't work for me, either. The only explanation I can think of is that we do not connect to an SQL database using the Imports System Data.SqlClient Namespace. We connect to a Mainframe using an RPC written in Cobol the we write a class module (in VB.Net) to connect to. We do the same type of DataBind though, so I don't understand...

---
Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest Community Website: http://www.dotnetjunkies.com/newsgroups/
Nov 20 '05 #12
You can try this after the grid is data bound:
lbl_test.Text = ItemGrid.Items(12).Cells(7).Text

Or, you can use the Item_DataBound event:

Protected Sub ItemGrid_DataBound(ByVal sender As Object, ByVal e As
DataGridItemEventArgs) _
Handles ItemGrid.ItemDataBound
If e.Item.ItemIndex = 12 Then
Session("wa_tot_gal") = e.Item.Cells(7).text
End If
End Sub
However, may I ask why you are doing this? it seems odd to bind the grid to
a datasource, then pull data out of that datagrid instead of getting the
data right from the source.

(Look at the DataTable's .Select() method, or the DataView's .RowFilter
property, etc...)

"coleenholley" <coleenholley@-NOSPAM-dmv.state.nv.us> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I've been trying since last Friday to get an answer on how to get a SPECIFIC row.cell value from a datagrid. I've had plenty of suggestions,
but nothing works to get the value from a SPECIFIC Row and cell. Right now
I have this code:
Sub Item_Bound(ByVal sender As Object, ByVal e As DataGridItemEventArgs)
lbl_test.Text = lbl_test.Text & " " & e.Item.ItemIndex
Session("wa_tot_gal") = e.Item.Cells(7).Text
Response.Write(Session("wa_tot_gal"))
End Sub

it returns:
1¢ Amount (NRS 373.030)000000000000000120

this information is from every row (including the header) I need the specific information for the value 12 returned to me so I can use that value
as a session variable that needs to populate another web page table. I can
NOT get it to return the SPECIFIC Row data! Please, can someone help me?
Thanks much, Coleen.

---
Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest

Community Website: http://www.dotnetjunkies.com/newsgroups/
Nov 20 '05 #13
Thanks Phil - Actually I haven't tried putting the code in the class module instead of the VB code-behind! We connect to a DB2 database that resides on a mainframe - we have class module written in VB.Net that gets the data from and RPC to COBOL -it's complicated. I haven't tried getting the data before the datagrid is complied, I thought I could do this like you do an ASP.Net table - but obviously not :-( Let me try this in the class module using the Select method like you suggest. Sometimes you need to think outside the box...Thanks!

---
Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest Community Website: http://www.dotnetjunkies.com/newsgroups/
Nov 20 '05 #14
Cor
Hi Coleen

When you can count 17 rows and 8 collumns than this code should work in my
opinion.

But if you message again, than I will check it again tomorrow.

Late here

Cor
Nov 20 '05 #15
Thanks so much Cor :-)

Just out of curiosity - what country are you in? It's 2:42 p.m. on the West Coast of the U.S. I REALLY appreciate all the help I am getting. Like I said, I think the problem is in the way we connect to the datatable. I'm currently trying to write this in the Class Module that we us to call the data from the RPC, per Phil's suggestion. I never thought of that...

I'll post back to this thread to let you know what the result is. I'm going to keep trying - there has to be a way to get this to work...

Thanks again - have a good evening :-)

Coleen
---
Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest Community Website: http://www.dotnetjunkies.com/newsgroups/
Nov 20 '05 #16
Cor
Hi Coleen,
What Phil was writing was my thought a long time before when you started
this project, I told it again in my message before the last one, not this,
but I got more and more the idea that you had user actions involved with
this project.

If you want to know how to build a datatable from a flat file than ask, I
have so many samples for that.

And I am Dutch

Cor
Nov 20 '05 #17
I dont know why you are getting the problem that you are, but you *can*
definately access the cells with the code I gave you, I do it all the time
and in fact I created that little snippet from inside one of my working
programs, hence the *'dgPeople'* identifier for the grid in the example.

Something is seriously wrong with what you are doing and its probably going
to be really simple to determine like you have two grids and your accessing
the wrong one or something.
OHM
coleenholley wrote:
Thanks so much Cor :-)

Just out of curiosity - what country are you in? It's 2:42 p.m. on
the West Coast of the U.S. I REALLY appreciate all the help I am
getting. Like I said, I think the problem is in the way we connect
to the datatable. I'm currently trying to write this in the Class
Module that we us to call the data from the RPC, per Phil's
suggestion. I never thought of that...

I'll post back to this thread to let you know what the result is.
I'm going to keep trying - there has to be a way to get this to
work...

Thanks again - have a good evening :-)

Coleen
---
Posted using Wimdows.net NntpNews Component - Posted from .NET's
Largest Community Website: http://www.dotnetjunkies.com/newsgroups/


--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com
Nov 20 '05 #18
Cor
HI OHM

I thought that it was a web datagrid (I hope I did understand it well)

Cor
Nov 20 '05 #19
Hi OHM, Cor and Phil :-)

Sorry I did not respond last night, but my hard drive crashed! As if I needed that! Well, to let you all know, I AM using a web datagrid. The connection is done through an RPC to a COBOL program which gets the data from a DB2 database on a Mainframe. I suspect that this is the reason I am having so much trouble with all of the examples I have been given. The page I am accessing only has one datagrid on it dtg_worksheet1 - I've tried all the code you've all sent, unfortunately, nothing seems to work for me. I have since moved to the Class module that calls the RPC, and written a function to store the value for the session variable and pass that value to the .aspx page. I haven't been able to test it yet, since my hard drive crashed. I am currently using someone else's computer that does not have the same software configuration that I did, and I can't run the debugger in VS.Net to test if my code from yesterday (before my system crashed) works. Got to tell you all how much I appreciate your help. I'll post back or start a new post (since there is so much out there for Feb4) later today once my system is up and running again. The good news is that we were able to save my data, so I won't have lost all my code...

Thanks again - Coleen

---
Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest Community Website: http://www.dotnetjunkies.com/newsgroups/
Nov 20 '05 #20
Sorry, my mistake. I cant help you at the moment, Im struggling like mad
witg SmartDocs.

regards

coleenholley wrote:
Hi OHM, Cor and Phil :-)

Sorry I did not respond last night, but my hard drive crashed! As if
I needed that! Well, to let you all know, I AM using a web datagrid.
The connection is done through an RPC to a COBOL program which gets
the data from a DB2 database on a Mainframe. I suspect that this is
the reason I am having so much trouble with all of the examples I
have been given. The page I am accessing only has one datagrid on it
dtg_worksheet1 - I've tried all the code you've all sent,
unfortunately, nothing seems to work for me. I have since moved to
the Class module that calls the RPC, and written a function to store
the value for the session variable and pass that value to the .aspx
page. I haven't been able to test it yet, since my hard drive
crashed. I am currently using someone else's computer that does not
have the same software configuration that I did, and I can't run the
debugger in VS.Net to test if my code from yesterday (before my
system crashed) works. Got to tell you all how much I appreciate
your help. I'll post back or start a new post (since there is so
much out there for Feb4) later today once my system is up and running
again. The good news is that we were able to save my data, so I
won't have lost all my code...

Thanks again - Coleen

---
Posted using Wimdows.net NntpNews Component - Posted from .NET's
Largest Community Website: http://www.dotnetjunkies.com/newsgroups/


--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com
Nov 20 '05 #21
Thanks for all the help/suggestions you have given OHM...I appreciate it. I will send a new post later today to let everyone know what the results are after my system is restored. I think (hope) I have it handled through the class module - I need to tell Phil thanks again for setting me on that path. I guess I just don't undertstand why the way we connect makes so much difference on how I have to get the Row/Cell values from the datagrid. Thanks again :-) Colee

P.S. Great big thanks to Phil and especially Cor :-)

---
Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest Community Website: http://www.dotnetjunkies.com/newsgroups/
Nov 20 '05 #22

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: duikboot | last post by:
Hi all, I'm trying to export a view tables from a Oracle database to a Mysql database. I create insert statements (they look alright), but it all goes wrong when I try to execute them in Mysql,...
1
by: LilleSkutt | last post by:
I am trying to create and instantiate a class into a created domain, so that I can unload the domain and replace the class (assembly .dll) while the main application is running, but I can't get it to...
14
by: TrvlOrm | last post by:
OK. After much playing around, I managed to get my frame page this far.. see code below. BUT...there are still errors with it, and what I would like to have happened is this: 1) On the Left...
1
by: Chua Wen Ching | last post by:
Hi there, I have some problems when reading XML file. 1. First this, is what i did, cause i can't seem to read "sub elements or tags" values, so i place those values into attributes like this....
4
by: steroche | last post by:
I would REALLY appreciate help please please please! Im sure it is probably blindingly obvious to most of you but I am totally in the dark here!I am lost - i thought i had finally figured out this...
0
by: Lemune | last post by:
Hello everyone. I'm creating windows service application to capture data from my PABX, and send the data to sql server. My question is how could my application know when that PABX is sending data...
6
by: Derek | last post by:
Hi all any one please help, i have a buttin in flash 8 which gets a form contact.php but when it is pressed the emial ruturns empty as follows 1 the flash button 2 the form 3 the email outcome...
2
by: Richard | last post by:
Help please. I am trying to autofill a form text field from a select-box lookup. I have no problem doing this if the select-box is part of the form but because there are 5 possible select boxes...
5
by: Ra7al143 | last post by:
hi everybody, i need help please with the following example: i have the following table: id -------------- coursenumber 123 -------------- ...
5
by: mvmashraf | last post by:
Hi to all.... I have spent some time browsing for a solution to the following error but have unfortunatly not found any solution yet ,Please any help would be much appreciated.......
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.