The things I learnt while I migrated from classic asp to asp.net is given here for my reference as well as for new beginners.

How to Create HyperLink in a Data Grid

How to create Hyper Link in a DataGrid?

Step : 1

First Create the Basic and Simple GridView. The code will look like this :

<asp:gridview ID="Gridview1" runat="server" AutoGenerateColumns="False"
DataKeyNames="EMP_ID" DataSourceID="myconn">
<Columns>
<asp:BoundField DataField="EMP_NAME" HeaderText="EMP_NAME"
SortExpression="EMP_NAME" />
<asp:BoundField DataField="SALARY" HeaderText="SALARY"
SortExpression="SALARY" />
<asp:BoundField DataField="EMP_ID" HeaderText="EMP_ID" ReadOnly="True"
SortExpression="EMP_ID" />
</Columns>
</asp:gridview>

The output for the above code will look like this:

EMP_NAME SALARY EMP_ID
ROJA 2000 6
RAJA   5

 

Step-2

Now Let us modify one of the columns as shown in red here:

<asp:gridview ID="Gridview1" runat="server" AutoGenerateColumns="False"
DataKeyNames="EMP_ID" DataSourceID="myconn">
<Columns>
<asp:BoundField DataField="EMP_NAME" HeaderText="EMP_NAME"
SortExpression="EMP_NAME" />
<asp:BoundField DataField="SALARY" HeaderText="SALARY"
SortExpression="SALARY" />
<asp:TemplateColumn HeaderText="Edit">
<ItemTemplate>
<asp:HyperLink Runat="server" NavigateUrl='<%# _
"EmpEdit.aspx?Emp_ID=" & Container.DataItem("Emp_Id") +& "&Emp_Name=" & Container.DataItem("Emp_Name") %>' />
</ItemTemplate>
</asp:TemplateColumn>

</Columns>
</asp:gridview>

 

 

Thanks for Your Visit

Google Search
Disclaimer and Copy Right