Click here to Skip to main content
15,901,426 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I need to get datakeynames from a gridview selected row, now this would be used to populate another gridview.

Please give me some example!

Thanks!
Posted

1 solution

I think you can get it in grid view selected index event:
void GridView1_SelectedIndexChanged(Object sender, EventArgs e)
 {

   // Determine the index of the selected row.
   int index = CustomersGridView.SelectedIndex;

   // Display the primary key value of the selected row.
   Message.Text = "The primary key value of the selected row is " +
       CustomersGridView.DataKeys[index].Value.ToString() + ".";

 }

If you want to display the popup on select row then you can read this article
http://www.aspdotnetcodes.com/Ajax_ModalPopup_PostBack_GridView.aspx[^]
 
Share this answer
 
v2
Comments
Ahsan Mirza 6-Jul-11 13:33pm    
But how to use it in second gridview?
Parwej Ahamad 6-Jul-11 13:40pm    
first you need learn how to show nested grid view so go with video:
http://www.youtube.com/watch?v=Qc53ZekBryE
and One more, put something efforts from your side too. Many articles are available.
Thanks
Ahsan Mirza 6-Jul-11 13:57pm    
No doubt brother you are very much right for the second point yet, i have been searching on my part for almost 3 days. I don't want to nest gridviews, i need to display 2nd grid view in a div which would open as a popup.
Parwej Ahamad 6-Jul-11 14:14pm    
Ok got your point, but you should clearly mention your requirement, I can not write the whole code at this moment but you can follow the below article:
http://www.ezzylearning.com/tutorial.aspx?tid=2861497
and Let me know if you have any question or doubt.
Ahsan Mirza 6-Jul-11 14:14pm    
Now anyone please help me!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900