Home All Groups Group Topic Archive Search About

Access individual item in a datagrid

Author
19 Mar 2005 8:16 PM
shadrik
Hi people. I've been pulling my hair out over this one. :)

Ive got a datagrid that contains values pulled from a sql query. its limited to one record because the record is unique in that it contains user login data (username password etc)

When the user enters their username and password, the sql query is pulled and returned to the datagrid.

from outside any of the datagrids event handlers, I need to be able to access individual cells in this one row grid. This obviously means I cant use the e(eventargs) calls.

any idea how I might do this?
p.s. language used is VB.net.

if youd like to email me privately (or post here I dont care:) my email is interventionwebdes***@hotmail.co.uk -- shadrik ------------------------------------------------------------------------ Posted via http://www.codecomments.com ------------------------------------------------------------------------

Author
19 Mar 2005 8:40 PM
Ken Cox [Microsoft MVP]
If you've already got the data into a dataset, why don't you look through
that for the piece of data that you need? Not sure why you feel you need to
look into the datagrid.

Perhaps you could give us some code and more detail?

Ken
Microsoft MVP [ASP.NET]
Toronto

Show quoteHide quote
"shadrik" <shadrik.1m5***@mail.codecomments.com> wrote in message
news:shadrik.1m5v9s@mail.codecomments.com...
>
> Hi people. I've been pulling my hair out over this one. :)
>
> Ive got a datagrid that contains values pulled from a sql query. its
> limited to one record because the record is unique in that it contains
> user login data (username password etc)
>
> When the user enters their username and password, the sql query is
> pulled and returned to the datagrid.
>
> from outside any of the datagrids event handlers, I need to be able to
> access individual cells in this one row grid. This obviously means I
> cant use the e(eventargs) calls.
>
> any idea how I might do this?
> p.s. language used is VB.net.
>
> if youd like to email me privately (or post here I dont care:) my email
> is interventionwebdes***@hotmail.co.uk
>
>
>
> --
> shadrik
> ------------------------------------------------------------------------
> Posted via http://www.codecomments.com
> ------------------------------------------------------------------------
>
Author
19 Mar 2005 10:15 PM
Byron Hopp
Ken,

I have the exact same question, (only different).  Lets say I filled a
DataSet with  the fields "AcctNo", "StoreNo", "UpcNo", and that the query
returned several records.  How do I extract the value for the different
fields for the current row the grid is displaying?  In my case my grid is in
an MDI child window with a toolbar, when the user clicks a button on the
toolbar I would like to grab the StoreNo value and create a report for the
current record, or row.

Byron...


Show quoteHide quote
"Ken Cox [Microsoft MVP]" <BANSPAMken_cox@sympatico.ca> wrote in message
news:%23cIRoPMLFHA.3628@TK2MSFTNGP10.phx.gbl...
> If you've already got the data into a dataset, why don't you look through
> that for the piece of data that you need? Not sure why you feel you need
> to look into the datagrid.
>
> Perhaps you could give us some code and more detail?
>
> Ken
> Microsoft MVP [ASP.NET]
> Toronto
>
> "shadrik" <shadrik.1m5***@mail.codecomments.com> wrote in message
> news:shadrik.1m5v9s@mail.codecomments.com...
>>
>> Hi people. I've been pulling my hair out over this one. :)
>>
>> Ive got a datagrid that contains values pulled from a sql query. its
>> limited to one record because the record is unique in that it contains
>> user login data (username password etc)
>>
>> When the user enters their username and password, the sql query is
>> pulled and returned to the datagrid.
>>
>> from outside any of the datagrids event handlers, I need to be able to
>> access individual cells in this one row grid. This obviously means I
>> cant use the e(eventargs) calls.
>>
>> any idea how I might do this?
>> p.s. language used is VB.net.
>>
>> if youd like to email me privately (or post here I dont care:) my email
>> is interventionwebdes***@hotmail.co.uk
>>
>>
>>
>> --
>> shadrik
>> ------------------------------------------------------------------------
>> Posted via http://www.codecomments.com
>> ------------------------------------------------------------------------
>>
>
Author
20 Mar 2005 1:23 AM
Ken Cox [Microsoft MVP]
Hi Byron,

You can check the value of any item within the dataitem during the
DataGrid.ItemDataBound Event

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebuiwebcontrolsdatagridclassitemdataboundtopic.asp

    Sub Item_Bound(sender As Object, e As DataGridItemEventArgs)

        Label1.Text = Label1.Text & " " & e.Item.ItemIndex
    End Sub 'Item_Bound

Ken