473,789 Members | 2,898 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Finding DataKey in GridView

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_Ro wDataBound(obje ct sender,
GridViewRowEven tArgs e)
{
int tableId = int.Parse(
BookGridView.Da taKeys[e.Row.DataItemI ndex].ToString() );

.....

}
Nov 24 '05 #1
1 1822
Hello mike,

Once you have specified DataKeyNames, you can retrieve the datakey for the
selected row by simply using - BookGridView.Se lectedValue

Cheers,
Sumeet

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_Ro wDataBound(obje ct sender,
GridViewRowEven tArgs e)
{
int tableId = int.Parse(
BookGridView.Da taKeys[e.Row.DataItemI ndex].ToString() );
.....

}

Nov 26 '05 #2

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

Similar topics

0
1225
by: Kivak Wolf | last post by:
Hey, I have a GridView in one web page that displays a bunch of data about companies; the DataKeyName is called "company_id". Now, when I click on a row command called "Modules" I want to copy the value of the data key contained in that row into a "Session" variable. How would I do that in ASP.NET 2.0 and VB.NET? Kivak Wolf
0
6926
by: mike | last post by:
how can i get datakey value of GridView ??????? protected void BookGridView_RowDataBound(object sender, GridViewRowEventArgs e) { int tableId = int.Parse( BookGridView.DataKeys.ToString() ); .....
1
8317
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 gridView that has 2 templated columns that contain drop-down lists. The first drop down list uses a value off of a formview on the same page for filtering. The 2nd drop-down is supposed to use the value off the first drop-down for it's...
3
17313
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 rowdatabound I want to do something like If (e.Row.RowType = DataControlRowType.DataRow) Then e.row.attribute.add("onClick", "alert('" + KeyID + "')'") End If but I don't know how to get the KeyID? Any help would be appreciated.
1
2730
by: Sean | last post by:
I have my gridview bound to a objectdatasource control and the only thing I need to hide on the grid is the primary key but I need the key in the dataset that refers to it. With a dynamic approach the column can be hidden at a certian point in the rendering cycle. As I have learned today my grid never offically has a column(0) and I would think anyone who ever uses the gridview would want to hide the primary key! Where/how/when can I...
0
1389
by: Stu | last post by:
Hiya, Im sure this is one of those easy if you know how type basically i have a dataview and i want to bind it to a gridview grdResults.DataSource=objDataSet.Tables.DefaultView; grdResults.DataBind(); However i want to set the key like in the old datagrid so i can access it on
1
6237
by: JeffBuzz | last post by:
I have searched high and low and cannot figure this out. I want programmatically select a row in my GridView based on a primary key value (DataKey). You would think this is common, but I guess not. It is easy to do when the data key is on the current page, but doesn't work when the key is on another page. Any ideas? Thanks, Jeff
1
40180
by: jc | last post by:
Duh.. How do I do this? CreditId is my datakey, but I can't seem to get to it. Dim dgItem As GridViewRow For Each dgItem In gridEmployeeCredits.Rows If dgItem.DataItem("CreditId") = 0 Then Dim textboxCreditDate As TextBox = CType(dgItem.FindControl("textboxCreditDate"), TextBox)
3
7696
by: =?Utf-8?B?V2FubmFiZQ==?= | last post by:
I have a gridview that has a label field and a checkbox field in it. I have the checkbox set to autopost when changed. How can I get the datakey value that is assigned to that row when a checkbox is either checked or unchecked?
0
9511
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10410
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10200
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10139
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9020
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5418
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2909
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.