473,779 Members | 1,921 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get Datakey from gridview row?

jc
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 gridEmployeeCre dits.Rows
If dgItem.DataItem ("CreditId") = 0 Then
Dim textboxCreditDa te As TextBox =
CType(dgItem.Fi ndControl("text boxCreditDate") , TextBox)
textboxCreditDa te.Text = ""
End If
Next

Thanks.
Mar 6 '08 #1
1 40178
Using the GridView.Select edValue property
you can get the data key value of the selected row in a GridView control
see here:
http://msdn2.microsoft.com/en-us/lib...ue(VS.80).aspx

Or if you want to get a collection of datakeys objects that represents the
data key value of each row in a GridView control, you can use the
GridView.DataKe ys property
see here:
http://msdn2.microsoft.com/en-us/lib...ys(VS.80).aspx
--

SorCereSs
MCTS: NET Framework 2.0 - Web-Based Client Development
MCPD: Web Developer
Microsoft Student Partner - Paraguay

Mar 6 '08 #2

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

Similar topics

1
1822
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 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.
5
13078
by: NH | last post by:
How do I find out the row index selected in the gridveiw row command method? I have an imageButton in a gridview cell and its corresponding code in the row command method needs to know the row index in question in order to set the background of the cell to a different color. But the selectedIndex value doesnt return a value as expected. Is there something I am missing?
1
2189
by: Steven Blair | last post by:
Here is my problem: I have a GridView with a Select column. Once the user clicks the Select button the following things need to happen. 1. Need to store the DataKey of the selectedindex 2. Open a new webform (size needs to be smaller than regular) 3. Using the previously cached DataKey populate a FormView in the new window.
1
1255
by: ram_kri | last post by:
Hi Guys, Here is a uncommon scenario that I had to work on.. I have a GridView which is associated to a DataSource. But I have a couple of columns (item-templates while the rest of the columns are boundfields)which have labels. Now, the datasouce that is bound to the GridView doesnt provide values to the itemTemplate columns. So in the page_load event I manually obtain the data from the DB and then process it, loop through the rows of...
3
28538
by: denvercr | last post by:
Hi how do i possibly get the value of a hidden column (id) of a gridview binded in sqldatasource? i have this code in C# usng GridViewRow and DataKey Classes to retrieve it, I also set the DataKeyNames to "id".. here is the code: GridViewRow gridViewRow; DataKey dataKey; gridViewRow = GridView.SelectedRow; dataKey = GridView.DataKeys; Label1.text = Convert.ToString(dataKey.Value); // This should display id value.
7
3337
by: =?Utf-8?B?V2FubmFiZQ==?= | last post by:
Is there a way to use a gridview in a timecard application, and if so, how? I was looking at using a gridview to display a person's hours worked in a week. To do this, many different data records would have to display on the same row to make up a week (the database has a new row for each day entered). But, from what I can tell, this keeps you from being able to use a gridview, because the gridview relies on one datakey per row (and there...
6
1986
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi I have a gridview control with a template column that has a textbox and when the control is bound to the datasource the textbox is filled ok. I then change what is in the textbox in the gridview control and in the gridview_RowDataBound event I have string DiscDescrip = Convert.ToString((e.Row.Cells.FindControl("txbxDiscgv") as TextBox ).Text); This returns what was initially loaded in the textbox but not what I had just changed it...
2
2882
by: furqi | last post by:
hello every body my name is furqan ahmed and i am new to asp.net and so to .net controls can any tell me what the following code is saying and what does datakey means thanxxx i am waiting for ur reply i shall be vey thankfull to ya <%@ Page language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server">
0
9632
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10302
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...
1
10071
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
9925
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8958
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...
1
7478
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5372
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...
1
4036
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3631
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.