Seo Services

How to find the ID   of grid view (on which user is click) using asp.net c# 


Here is Two Technique by using both of them we can find the ID of gridview in asp.net C#.

1.  Using Command argument 

2. Without Command Argument


           1. Using Command argument :-

                                                                Using this technique we should have a CommandName on our aspx page .

Ex.   Home .aspx page  inside grid view                

       <asp:Button ID="cmdEdit" runat="server" CommandName="cnEdit" CommandArgument='<%# Eval("ID") %>' Text="Edit" />

Home.aspx.cs page 

Response.Redirect("RegistrationForm.aspx?ID="+ e.CommandArgument);



2.Without Command Argument


Home.aspx 

  <asp:Button ID="cmdEdit" runat="server" 

                                     commandName="cnEdit" Text="Edit" />


Home.aspx.cs 



Response.Redirect("RegistrationForm.aspx?ID="+ ID);

 int ID = Convert.ToInt16(GvGetRecord.DataKeys[0].Values["ID"]);
























Reviewed by Unknown on September 25, 2018 Rating: 5

No comments:

ads 728x90 B
Powered by Blogger.