GridView with Hyperlink

Recently we have encountered a requirement where there is a page with simple details and a link for each record in that page take you to another page. This another page would have all the details of the selected record of the previous page. Let me rename these as ClassRoomPage containing the names of the students and their respective roll numbers and the second page is StudentDetailsPage where we pass a parameter as Student ID.

So what we did is, we had the first page as ClassRoomPage with GridView and binded that with the respective columns. The trick is that we need a hyperlink to navigate to the next page along with the query parameter. So we added a template column with the hyperlink as mentioned below

<asp:TemplateField HeaderText="Comment">
<
ItemTemplate>
<
asp:HyperLink id="hlview" runat="server" NavigateUrl='<%#"~/StudentDetails.aspx?RollNumber="+ Eval("RollNum") %>' Text="View" />
</
ItemTemplate>
</
asp:TemplateField>

Now that we have the both pages, all we need is to do is bind the first page with the ClassRoomDetails and this would add an extra column to the right side of the record and that takes you to the navigation for the next page. What do you say?

Comments

Popular posts from this blog

Network Intrusion Detection using Supervised ML technique

Common mistakes by Interviewer

Keep the system active, to avoid the auto lock