Saturday 12 January 2013

DataKey get a gridview


Question :

Using VS2010, C #, AspNet4
I principal.aspx page, contains a GridView1 with fields Id and Name, Id is the DataKey.
Select any line on the grid and open a new page called editar.aspx.
How using a button, I get the Id of the selected row to edit the page editar.aspx
Answer :
You can use hyperlinkfield to open editor.aspx

ASPX
<hyperlinkfield Text="Edit Data" DataNavigateUrlFields="ID"
DataNavigateUrlFormatString="editar.aspx?id={0} />

in editar.aspx use querystring("id") to filter the data.
It's not using selected row and datakeyname. Hyperlink only

source : http://forums.asp.net/t/1820678.aspx/1?DataKey+get+a+gridview

No comments:

Post a Comment