473,513 Members | 10,313 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

aligning datagrid with datasource

hi folks,

which is the best way to get to the datasource/row via a bound datagrid?

my datagrid is bound to a dataview.
when i select a button in the grid i want easy access to the
corresponding datarowview in the dataview.

until now my best bet is to get the datakey from the
datagrid.SelectedItem, sort my view by the key´s field and then use
dataview.Find() to get the row. but thats horribly cubersome and sorts
my view in a way i do not like it to be sorted!

i am very sure there must be a much better method which i haven't found
yet - please tell me :)

thanks
jj

Nov 17 '05 #1
2 1082
Hi Jan,
it seems you need to use the
System.Web.UI.WebControls.DataGridCommandEventArgs parameter passed to the
event handler: it has an Item property which in turn has a DataItem property
that references the DataRowView you need to access.

Hope it helps,
Luca

"Jan Limpens" <re******************@sneakemail.com.delete-this.here> wrote
in message news:uh**************@tk2msftngp13.phx.gbl...
hi folks,

which is the best way to get to the datasource/row via a bound datagrid?

my datagrid is bound to a dataview.
when i select a button in the grid i want easy access to the
corresponding datarowview in the dataview.

until now my best bet is to get the datakey from the
datagrid.SelectedItem, sort my view by the key´s field and then use
dataview.Find() to get the row. but thats horribly cubersome and sorts
my view in a way i do not like it to be sorted!

i am very sure there must be a much better method which i haven't found
yet - please tell me :)

thanks
jj

Nov 17 '05 #2
it does, thanks!

Luca Bertoldi wrote:
Hi Jan,
it seems you need to use the
System.Web.UI.WebControls.DataGridCommandEventArgs parameter passed to the
event handler: it has an Item property which in turn has a DataItem property
that references the DataRowView you need to access.

Hope it helps,
Luca


Nov 17 '05 #3

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

Similar topics

2
4316
by: pei_world | last post by:
I want to implement a key hit with enter to dropdown a combobox that is in the datagrid. in this case I need to override its original behaviours. I found some codes from the web. Does anyone know...
2
2737
by: Dave | last post by:
Hello all, I need to know if you can vertically align Items within an ItemTemplate. For example I have two columns, one column has a stack of 6 textboxes, my second column can have 1 to n...
1
4282
by: Rick | last post by:
Hello all, I hope all is well with you. I am having a seriously difficult time with this problem. Allow me to set up the problem. I have a System.Web.UI.Page with the following controls...
4
3477
by: tshad | last post by:
I am having trouble with links in my DataGrid. I have Links all over my page set to smaller and they are consistant all over the page in both Mozilla and IE, except for the DataGrid. Here is a...
1
1308
by: Jennifer | last post by:
I have a datagrid where I am trying to align some columns to the center. The rest should be aligned to the right. When I try the code below I get an error message saying that the index is out of...
1
3988
by: nemo | last post by:
I'm creating a datasource and populating a datagrid at runtime. The code is as follows: dt = New DataTable dt.Columns.Add(New DataColumn("Item", GetType(String))) dt.Columns.Add(New...
1
2352
by: jimb | last post by:
I can get the dropdownlist into the datagrid, and I can populate it, but I can't read it. Anybody have a working example of a dropdownlist in an editable grid? Thanks. -- .....
4
2262
by: Jan Nielsen | last post by:
Hi all I'm a former Access developer who would like to implement a many-to-many relation in about the same way you do in Access: With a subform and a combo box. Is it possible to use a...
8
3053
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
7153
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
7373
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,...
1
7094
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
7519
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
5677
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
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3218
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
452
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.