Home > Interview Questions > ASP.NET > what is use of DataKeynames attribute in gridview?

what is use of DataKeynames attribute in gridview?

by KiranReddy   on 22/05/2014   Category: ASP.NET   |  Level: Intermediate   |  Views: 1721    |  Points: 25     |  Starter 

->It is used to get value of primary key column in Grid view .
->Using this It is possible to delete a row in edit mode in gridview
ex----<asp:Gridview ID="gdv" runat= "server" DataKeyNames="primarykey column name"></asp:Gridview>

in code behind we get value

int Id = Convert.ToInt32(gdv.DataKeys[e.RowIndex].Values[0]);

using this Id we can delete any row in gridview edit mode also

try it please comment if u like this

« problèm with arabic exporting datatable to excel
» How to Implement Mvc4 Crud Operation With Paginations
Post Question  |  Question Home

Recent Posts

User Responses

  Re :what is use of DataKeynames attribute in gridview?   
Posted by Webspidy
on 28/05/2014
Points : 5

thank you very much for this code snippet.

Submit feedback about this code snippet

Please sign in to post feedback

Latest Posts