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

Datakey in Datagrid

Hello,

I am developing a Datagrid thar insert, delete and update rows in a Table.
This table has got 2 fields that are primary key. How can i detect which row
is selected to delete??
Thanks,

Asier
Nov 17 '05 #1
3 2235
"J. Ormaetxe" <jo***@viajesecuador.net> wrote in message
news:OF**************@tk2msftngp13.phx.gbl...
Hello,

I am developing a Datagrid thar insert, delete and update rows in a Table.
This table has got 2 fields that are primary key. How can i detect which row is selected to delete??
Thanks, Hi!
By implementing the onitemdelete event.
private void yourgrid_DeleteCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)

{


}

parameter e contains both datakeys and command data...

Asier


Nov 17 '05 #2
Thanks, but i dont'n know what is exactly the sentence to write.
Can you write an example of this event please??

Thanks a lot

"Egbert Nierop (MVP for IIS)" <eg***********@nospam.com> escribió en el
mensaje news:up**************@TK2MSFTNGP12.phx.gbl...
"J. Ormaetxe" <jo***@viajesecuador.net> wrote in message
news:OF**************@tk2msftngp13.phx.gbl...
Hello,

I am developing a Datagrid thar insert, delete and update rows in a Table. This table has got 2 fields that are primary key. How can i detect which

row
is selected to delete??
Thanks,

Hi!
By implementing the onitemdelete event.
private void yourgrid_DeleteCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)

{


}

parameter e contains both datakeys and command data...

Asier

Nov 17 '05 #3


"J. Ormaetxe" <jo***@viajesecuador.net> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
Thanks, but i dont'n know what is exactly the sentence to write.
Can you write an example of this event please??
private void yourGrid_DeleteCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)

{

int key = (int)yourGrid.DataKeys[e.Item.ItemIndex];

}

Of course, this only works if you have defined the primary key at design.
Thanks a lot

"Egbert Nierop (MVP for IIS)" <eg***********@nospam.com> escribió en el
mensaje news:up**************@TK2MSFTNGP12.phx.gbl...
"J. Ormaetxe" <jo***@viajesecuador.net> wrote in message


Nov 17 '05 #4

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

Similar topics

2
by: Alex | last post by:
I'm wondering how I can add data to the datakey property of the DataGrid. It seems to be read only. How can I populate it? I'm using data bound columns, however do not autogenerate the entire grid...
7
by: Andy Sutorius | last post by:
Hi, I have a datalist with a asp:button. I have onitemcommand firing when the button is clicked. I am attempting to get the datakey of the button that was clicked. I can retrieve a specific...
3
by: Eustice Scrubb | last post by:
When deleting in a Datagrid, I'm using a Datakey to reference the deletion since the specific table I'm deleting from doesn't have a index or ID for each entry. Sub myDataGrid_Delete(ByVal...
7
by: Joel Reinford | last post by:
I am looking for a way to set the selectedindex of a datagrid based on the datakey value. For example given this grid with a datakey of OrderID: OrderID Item 54 A 98 ...
1
by: mike | last post by:
i'd like to get datakey of GridView So i write code like below but it wasn't work well. how should i do? protected void BookGridView_RowDataBound(object sender, GridViewRowEventArgs e) { int...
1
by: Mark Richards | last post by:
I posted this earlier, and got no response. Basically I need to be able to grab a value from one of the fields in a gridView to populate a dropdown in another column of the gridview: I have a...
3
by: MasterChief | last post by:
I am trying to add an attribute to a gridview row so when you click on it, it will pop up an alert saying the current datakey for that row. How is it possible to get a datakey when using the...
2
by: Rod | last post by:
While working with a datagrid I have a value for the datakey, from this I want to find the ItemIndex. How please? many thanks in advance.
5
by: jrobbins | last post by:
public IEnumerable<AuthorizationObjectClass> GetEmployeeNoAuthorizations(SqlInt32 PersonnelNumber) { DataSet ds; AuthorizationObjectClass auth = new...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
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
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...

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.