Click here to Skip to main content
15,892,809 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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;
Posted
Comments
s_rao88 26-Jun-13 7:07am    
please repl me ... i struggling with this ting since past 2 days

You can use COOKIES,SESSION or QueryString to retrieve value from onr page to another page....

:)
 
Share this answer
 
Comments
s_rao88 26-Jun-13 7:19am    
i have used sessio thr above.. but please tell me wethr its in propr format
Try This....:)

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



Just send TaskID to another page and by reference of TaskID you can easily retrieve all information from database with the help of DataSet or DataTable....there is no need to use multiple sessions...and it is also very secure way.....:)
 
Share this answer
 
Comments
s_rao88 26-Jun-13 7:33am    
i guess u havent went through the code which i have posted ther... i have written the same code in my GridView_OnRowDataBound
Nirav Prabtani 26-Jun-13 7:36am    
yes same code i have paste there i just want to say,......
Just send TaskID to another page and by reference of TaskID you can easily retrieve all information from database with the help of DataSet or DataTable....there is no need to use multiple sessions...and it is also very secure way.....
s_rao88 26-Jun-13 7:38am    
okie got ur point... i did it but values not getting passed .. only empty labels are displaying in another page
s_rao88 26-Jun-13 7:39am    
objc.TaskID = Convert.ToInt32(Session["TaskID"]);
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;


this is wat i used to display the values in anothr page
s_rao88 26-Jun-13 7:40am    
GetReports is my stored procedure

it goes like this...


ALTER PROCEDURE [dbo].[GetReports]

@TaskID int

AS

Select TaskName, DueDate, Description, AssignBy, Status, PercentageComplete

From dbo.Task

Where TaskID = @TaskID;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



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