While working with GridView in ASP.NET, most of the time we used HyperlinkField column to navigate from one page to different page with some value as argument. In this blog post I have explained how can we pass multiple parameter with HyperLinkField in GridView.
To implement this features you need to know about DataNavigationUrlField and DataNavigateUrlFormatString properties of HyperLinkField. Let’s assume that you have a gridview as given below and you have already bind the datasource from code behind.
<asp:gridview id="GrdEmp"> <columns runat="server" autogeneratecolumns="False" cellpadding="4"> <asp:boundfield datafield="ID" headertext="ID" /> <asp:boundfield datafield="Name" headertext="Name" /> <asp:boundfield datafield="ParentID" headertext="Base ID" /> </columns> </asp:gridview>
Let’s first consider the case of passing single parameter. First thing that you need to do is, add a GridView “HyperLinkField “ column. After that you need to set the DataNavigationUrlField and DataNavigateUrlFormatString properties for the same . In DataNavigationUrlField you have to mention the name of the DataField which you want to bind as querystring. In DataNavigateUrlFormatString you have to give the formatted URL String for the Navigation. The concept is same here as like FormatString the only difference is the data is coming from DataNavigationUrlField .
Read More “How to pass multiple values using GridView HyperLinkField ?”