473,406 Members | 2,956 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,406 software developers and data experts.

How to get values from selected item in a gridview

Hi all, just as I'd got the hang of datagrids in 1.1 they change to gridviews
and everything is done differentley...... I'm really stuck so help would be
appreciated!

I've got a gridview which has a select command. When the user clicks the
select command I want the data from the selected row to be pasted into some
controls/fields I have, the problem is that I can't seem to be able to get
the data, here's one of the variations i've tried:

Private Sub dgDepts_RowCommand(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewCommandEventArgs ) Handles dgDepts.RowCommand
If e.CommandName.Equals("Select") Then
'populate the department edit fields with the data from the
selected record
Me.tbDept.Text = Me.dgDepts.SelectedRow.Cells(0).Text
End If
End Sub

I get an error message at Me.dgDepts.SelectedRow.Cells(0).Text as it's
showing as nothing.

I've also tried me.dgDepts.sSlectedDataKey.Item(0).ToString but get the same
message (although I'm not sure I really understand this new datakey lark).

I've searched high and low to get examples of how to do this and have found
lots but nothing that matches what I need to do.

Any clues greatly appreciated.
Julia

Oct 8 '08 #1
0 1803

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

Similar topics

4
by: krzysiek | last post by:
hello, i have several radiolists and checkboxlist that are generated dinamicly based on datasource. So frankly speaking i don't know names and number of that web controls cose they are always...
3
by: Richard Albrecht | last post by:
I have been trying to figure out for days on how to read values from a Bound ListBox. The listBox gets the values from an Access Table. I can read values fine for Non-Bound ListBoxes, But the...
5
by: Dick | last post by:
I have a GridView bound to an ObjectDataSource. I have a Button that calls GridView.DataBind. I want the row that is selected before the DataBind to still be selected afterwards. This happens...
2
by: NH | last post by:
How can I set the selected item in a dropdownlist which is declared in the edititemtemlpate of a gridview? Which gridview event should I use, I cant seem to figure it out...
3
by: podi | last post by:
Hi, I just wonder if there is a way to set a selected item in dropdown list which items are retreived from database without touching c# code ? I mean, i have in gridview, in edit mode one...
1
by: Dinu | last post by:
hi i am having a gridview in aspx page and a usercontrol in master page of that page now what i want is selected row text to be displayed in usercontrol i wrote code as follows: ...
1
by: =?Utf-8?B?Um9iZXJ0IFNtaXRo?= | last post by:
Hi, I have a problem whereby I have a gridview bound to a dataset with a large number of items, However when I select an item near the bottom by using the scrollbar, when the gridview gets...
6
by: SAL | last post by:
hello, I'm using a radiobuttonlist in an updatepanel in an item template in a Gridview control. I'm populating the radiobuttonlist in the RowDataBound event. I have the control toolkit registered...
1
by: renuami | last post by:
Hello friends please advise....... I am building an application for Survey. For this i have GridView with two Template fields. The first Template has Label (To display question text) and...
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
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
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
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.