Find data key Id in GridView [Resolved]

Posted by Sudhakar_A under ASP.NET on 11/11/2013 | Points: 10 | Views : 3931 | Status : [Member] | Replies : 5
I have grid-view and nested grid-view. Now I am try to update the row form the inner grid-view. I have an event like grd_RowUpdating(object sender, GridViewUpdateEventArgs e). How to find the data-key name form inner grid-view on RowUpdating() event.




Responses

Posted by: Allemahesh on: 11/11/2013 [Member] [MVP] Silver | Points: 50

Up
0
Down

Resolved
Dear Sudhakar,

You can use the below code for this:-

GridViewRow gvRowParent = ((GridView)sender).NamingContainer as GridViewRow;
int _ID = Convert.ToInt32(gvInner.DataKeys[gvRowParent.RowIndex].Value.ToString());


Happy Coding,
If it helps you or directs U towards the solution, MARK IT AS ANSWER

Sudhakar_A, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 11/11/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Are you using a DataSourceControl?


You can always use the EditIndex, in the RowUpdated event, for example:

string ID = GridView1.DataKeys[GridView1.EditIndex].Value.ToString();



Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Sudhakar_A, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sudhakar_A on: 11/11/2013 [Member] Starter | Points: 25

Up
0
Down
I m not using Datasource control

Sudhakar_A, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 11/11/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Refer
http://stackoverflow.com/questions/11008686/nested-gridview-get-parent-row
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowupdating(v=vs.110).aspx
http://stackoverflow.com/questions/17540461/how-to-find-datakey-value-of-gridview-on-selected-index-changed-property

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Sudhakar_A, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 11/11/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Samples of Nested GridViews
http://www.codeproject.com/Questions/294777/Gridview-nested-on-another-gridview-getting-the-da
http://www.freedotnetapps.com/asp-net/how-to-display-gridview-inside-gridview-i-e-nested-gridview-in-asp-net/
http://www.aspdotnet-suresh.com/2012/05/gridview-with-in-gridview-or-nested.html
http://stackoverflow.com/questions/11008686/nested-gridview-get-parent-row
http://hspinfo.wordpress.com/2008/10/01/how-to-get-datakeys-value-for-multiple-datakeynames-in-a-gridview-for-aspnet-20/

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Sudhakar_A, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response