how to determine which row is selected by cliking one button in a gridview?
-
I add one button for each row in a gridview, then some process will be carried out by cliking the button, first of all, the selected row should be identified by clicking the button, but I do not know which function should be used? thank you for your help in advance!
-
I add one button for each row in a gridview, then some process will be carried out by cliking the button, first of all, the selected row should be identified by clicking the button, but I do not know which function should be used? thank you for your help in advance!
Use GridView
RowCommand
Event http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowcommand.aspx[^]Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.
-
Use GridView
RowCommand
Event http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowcommand.aspx[^]Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.
You can use RowCommandEvent like this. e.Command name give thename of your button you gave in aspx. Now do whatever you want to do. You can also use RowdataBound event. protected void gvCardFeesRReport_RowCommand(object sender, GridViewCommandEventArgs e) { try { switch (e.CommandName) { case "First": gvCardFeesRReport.PageIndex = 0; break; case "Prev": if (gvCardFeesRReport.PageIndex > 0) gvCardFeesRReport.PageIndex = gvCardFeesRReport.PageIndex - 1; break; case "Next": if (gvCardFeesRReport.PageIndex < gvCardFeesRReport.PageCount - 1) gvCardFeesRReport.PageIndex = gvCardFeesRReport.PageIndex + 1; break; case "Last": gvCardFeesRReport.PageIndex = gvCardFeesRReport.PageCount - 1; break; } } catch (System.Threading.ThreadAbortException) { }
Inderjeet Kaur Sr. Software Engg