How to get Datakey from gridview row?

J

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 gridEmployeeCredits.Rows
If dgItem.DataItem("CreditId") = 0 Then
Dim textboxCreditDate As TextBox =
CType(dgItem.FindControl("textboxCreditDate"), TextBox)
textboxCreditDate.Text = ""
End If
Next

Thanks.
 
T

Teresita Núñez - SorCereSs -

Using the GridView.SelectedValue property
you can get the data key value of the selected row in a GridView control
see here:
http://msdn2.microsoft.com/en-us/li...ebcontrols.gridview.selectedvalue(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.DataKeys property
see here:
http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.datakeys(VS.80).aspx
--

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top