Click here to Skip to main content
15,892,298 members

hyperlink in grid view row should display values in another page

s_rao88 asked:

Open original thread
i have got one gridview which consists o hyperlink in oneof the column (called as view details) upon clicking that hyperlink the details of particular row of that grid view should display in a labels of another page.

please help me out. so ar i have tried this.

this is my grid view

<asp:GridView ID="GrdViewMyTasks" runat="server" AllowSorting="True"
AutoGenerateColumns="False" BackColor="White" BorderColor="#0061C1"
BorderStyle="None" CaptionAlign="Bottom" EmptyDataText="No Records Found"
Font-Names="Verdana" Font-Size="X-Small" ForeColor="#0061C1"
Height="179px" OnRowDataBound="GrdViewMyTasks_RowDataBound" ShowFooter="True" ShowHeaderWhenEmpty="True" Width="99%" onselectedindexchanged="GrdViewMyTasks_SelectedIndexChanged" OnRowCreated="GrdViewMyTasks_RowCreated" >

<columns><asp:BoundField DataField="Gen_ID" HeaderText="SL No" ReadOnly="True"
Visible="False">
<footerstyle backcolor="#0061C1">
<HeaderStyle BackColor="#0061C1"
HorizontalAlign="Center" VerticalAlign="Middle" />
<itemstyle horizontalalign="Center" verticalalign="Middle">

<asp:TemplateField HeaderText="Task Name">
<itemtemplate>
<asp:Label ID="TaskName" runat="server"
Font-Names="Verdana" Font-Size="X-Small" Height="24px"
Text='<%# Eval("TaskName")%>' Width="70px">

<footerstyle backcolor="#0061C1">
<HeaderStyle BackColor="#0061C1" ForeColor="White" />
<itemstyle horizontalalign="Center" verticalalign="Middle">


<asp:TemplateField HeaderText="Due Date">
<itemtemplate>
<asp:Label ID="DueDate" runat="server"
Font-Names="Verdana" Font-Size="X-Small"
Height="20px" Width="70px" Text='<%# Eval("DueDate","{0:dd/MM/yyyy}")%>' DataFormatString="{0:dd/MM/yyyy}">

<footerstyle backcolor="#0061C1">
<HeaderStyle BackColor="#0061C1" ForeColor="White" />
<itemstyle horizontalalign="Center" verticalalign="Middle">

<asp:TemplateField HeaderText="Description">
<itemtemplate>
<asp:Label ID="Description" runat="server"
Font-Names="Verdana" Font-Size="X-Small" Height="20px" Width="90px" Text='<%# Eval("Description")%>'>

<footerstyle backcolor="#0061C1">
<HeaderStyle BackColor="#0061C1" ForeColor="White" />
<itemstyle horizontalalign="Left" verticalalign="Middle">

<asp:TemplateField HeaderText="Assign By">
<itemtemplate>
<asp:Label ID="AssignBy" runat="server"
Font-Names="Verdana" Font-Size="X-Small" Height="20px" Width="90px" Text='<%# Eval("AssignBy")%>'>

<footerstyle backcolor="#0061C1">
<HeaderStyle BackColor="#0061C1" ForeColor="White" />
<itemstyle horizontalalign="Center" verticalalign="Middle">

<asp:TemplateField HeaderText="Status">
<itemtemplate>
<asp:Label ID="Status" runat="server"
Font-Names="Verdana" Font-Size="X-Small" Height="20px" Width="90px" Text='<%# Eval("Status")%>'>

<footerstyle backcolor="#0061C1">
<HeaderStyle BackColor="#0061C1" ForeColor="White" />
<itemstyle horizontalalign="Center" verticalalign="Middle">

<asp:TemplateField HeaderText="% Complete">
<itemtemplate>
<asp:Label ID="PercentageComplete" runat="server"
Font-Names="Verdana" Font-Size="X-Small"
Height="20px" Width="50px" Text='<%# Eval("PercentageComplete")%>'>

<footerstyle backcolor="#0061C1">
<HeaderStyle BackColor="#0061C1" ForeColor="White" />
<itemstyle horizontalalign="Center" verticalalign="Middle">

<asp:TemplateField HeaderText="View Details">
<itemtemplate>
<asp:HyperLink ID="ViewDetails" runat="server" Font-Names="Verdana" Font-Size="X-Small" Height="24px"
Text="View" Width="70px" NavigateUrl="Reports.aspx" ForeColor="#0061C1" DataTextField="TaskID" DataNavigateUrlFields="TaskID" DataNavigateUrlFormatString="Reports.aspx?TaskID={0}">View

<footerstyle backcolor="#0061C1">
<HeaderStyle BackColor="#0061C1" ForeColor="White" />
<itemstyle horizontalalign="Center" verticalalign="Middle">

this is my code behind for grid view on row data bound

if (e.Row.RowType == DataControlRowType.DataRow)
{
HyperLink ViewDetails = e.Row.FindControl("ViewDetails") as HyperLink;
ViewDetails.NavigateUrl = "Reports.aspx?TaskID=" + e.Row.Cells[0].Text;
}

here is my code behind or reports.aspx where the details of the grid view should be displayed

LblTaskID.Text = Session["TaskID"].ToString();
LblTaskName.Text = Session["TaskName"].ToString();
LblAssignBy.Text = Session["AssignBy"].ToString();
LblDescription.Text = Session["Description"].ToString();
LblDueDate.Text = Session["DueDate"].ToString();
LblStatus.Text = Session["Status"].ToString();
LblPercentageComplete.Text = Session["PercentageComplete"].ToString();

DataSet rep = obj.GetReports(objc);
DataView Rprts = new DataView();
Rprts.Table = rep.Tables[0];

LblTaskID.Visible = false;
LblTaskName.Visible = true;
LblAssignBy.Visible = true;
LblDescription.Visible = true;
LblDueDate.Visible = true;
LblStatus.Visible = true;
LblPercentageComplete.Visible = true;
LblAssignTo.Visible = false;
Tags: C#, ASP.NET, Gridview

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900