473,414 Members | 1,843 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.

another simple datagrid question

how can i get the value from a specific column from the selected row of a
datagrid

in the sub i can get the datakey for item command
Me.dgMems.DataKeys(e.Item.ItemIndex) will get me the key field, but what if
i want the value of column(2). I get nothing when i use
Me.dgMems.Columns(2).ToString(). View state is on.

thanks
(and i hope i don't have to refill the dataset on each select!)
kes

--
thanks (as always)
some day i''m gona pay this forum back for all the help i''m getting
kes
Nov 19 '05 #1
5 1512
If you use the OnItemCommand, you can pickup the value quite easily using
e.Item.Cells[2].Text;
or
((TextBox)e.Items.FindControl("tb")).Text; //If it is not a
<Asp:BoundColumn you'll need to cast it

HTH
"WebBuilder451" <We***********@discussions.microsoft.com> wrote in message
news:76**********************************@microsof t.com...
how can i get the value from a specific column from the selected row of a
datagrid

in the sub i can get the datakey for item command
Me.dgMems.DataKeys(e.Item.ItemIndex) will get me the key field, but what
if
i want the value of column(2). I get nothing when i use
Me.dgMems.Columns(2).ToString(). View state is on.

thanks
(and i hope i don't have to refill the dataset on each select!)
kes

--
thanks (as always)
some day i''m gona pay this forum back for all the help i''m getting
kes

Nov 19 '05 #2
try this (assuming Label is the first control and language c#):

string the_value = (MyRow.Cells[2].Controls[0]) as Label.Text;
"WebBuilder451" <We***********@discussions.microsoft.com> wrote in message
news:76**********************************@microsof t.com...
how can i get the value from a specific column from the selected row of a
datagrid

in the sub i can get the datakey for item command
Me.dgMems.DataKeys(e.Item.ItemIndex) will get me the key field, but what
if
i want the value of column(2). I get nothing when i use
Me.dgMems.Columns(2).ToString(). View state is on.

thanks
(and i hope i don't have to refill the dataset on each select!)
kes

--
thanks (as always)
some day i''m gona pay this forum back for all the help i''m getting
kes

Nov 19 '05 #3
e.Item.Cells(2)

Eliyahu

"WebBuilder451" <We***********@discussions.microsoft.com> wrote in message
news:76**********************************@microsof t.com...
how can i get the value from a specific column from the selected row of a
datagrid

in the sub i can get the datakey for item command
Me.dgMems.DataKeys(e.Item.ItemIndex) will get me the key field, but what if i want the value of column(2). I get nothing when i use
Me.dgMems.Columns(2).ToString(). View state is on.

thanks
(and i hope i don't have to refill the dataset on each select!)
kes

--
thanks (as always)
some day i''m gona pay this forum back for all the help i''m getting
kes

Nov 19 '05 #4
e.Item.Cells(2).Text

Eliyahu

"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:eZ**************@TK2MSFTNGP12.phx.gbl...
e.Item.Cells(2)

Eliyahu

"WebBuilder451" <We***********@discussions.microsoft.com> wrote in message
news:76**********************************@microsof t.com...
how can i get the value from a specific column from the selected row of a datagrid

in the sub i can get the datakey for item command
Me.dgMems.DataKeys(e.Item.ItemIndex) will get me the key field, but what

if
i want the value of column(2). I get nothing when i use
Me.dgMems.Columns(2).ToString(). View state is on.

thanks
(and i hope i don't have to refill the dataset on each select!)
kes

--
thanks (as always)
some day i''m gona pay this forum back for all the help i''m getting
kes


Nov 19 '05 #5
thanks everyone,
i knew it just had to be simple!

--
thanks (as always)
some day i''m gona pay this forum back for all the help i''m getting
kes
"Grant Merwitz" wrote:
If you use the OnItemCommand, you can pickup the value quite easily using
e.Item.Cells[2].Text;
or
((TextBox)e.Items.FindControl("tb")).Text; //If it is not a
<Asp:BoundColumn you'll need to cast it

HTH
"WebBuilder451" <We***********@discussions.microsoft.com> wrote in message
news:76**********************************@microsof t.com...
how can i get the value from a specific column from the selected row of a
datagrid

in the sub i can get the datakey for item command
Me.dgMems.DataKeys(e.Item.ItemIndex) will get me the key field, but what
if
i want the value of column(2). I get nothing when i use
Me.dgMems.Columns(2).ToString(). View state is on.

thanks
(and i hope i don't have to refill the dataset on each select!)
kes

--
thanks (as always)
some day i''m gona pay this forum back for all the help i''m getting
kes


Nov 19 '05 #6

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

Similar topics

1
by: serge calderara | last post by:
Dear all, I have a simple datagrid binding to a datasource dataset object that collect a simple table from a database. When I get data from that table, my datagrid appeard with a tree node...
7
by: Sky | last post by:
What I have currently: I have a user control called mod_container.aspx that is basically two divs -- the top a toolbar, that expands/collapse the second div which can contain other...
2
by: Bart Schelkens | last post by:
Sorry but I have another question about a button in a datagrid. I have the following button in my datagrid : asp:TemplateColumn HeaderText=""> <HeaderStyle width="20px"></HeaderStyle>...
5
by: Lyners | last post by:
What I want to do, I have a datagrid with totals in one column and a text field in the next. What I would like to provide is a way for the user to click on an arrow under/next to the total amount...
5
by: Nathan Sokalski | last post by:
I am writing an ASP.NET application in which I need to copy DataRows from one DataTable to another. When I use code such as the following: temprows = nodes.Select("state='PA'")...
2
by: Rich Wallace | last post by:
I know datasets have been beaten to death in here, I have what is hopefully a simple question about the integrity of a dataset when used in an application. Scenario: User A and User B are...
2
by: James | last post by:
I have a very simple datagrid, with an edit button that I added in PropertyBuilder. This fires the EditCommand event just fine and I show a panel where the user can edit certain fields. I have a...
13
by: shookim | last post by:
I don't care how one suggests I do it, but I've been searching for days on how to implement this concept. I'm trying to use some kind of grid control (doesn't have to be a grid control, whatever...
2
by: SePp | last post by:
Hi all. I want to refresh a Datagrid from another form. For Example I have a Datagrid in that I want to edit data. The user has the ability to press a button to change these data. A new Form...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.