i have a gridview which consists of hyperlink in one of 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(reports.aspx) .
please help me out. so far i have tried this.
this is my grid view
</asp:TemplateField>
<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" DataTexField="ID" DataNavigateUrlFields="TaskID" DataNavigateUrlFormatString="Reports.aspx?TaskID={0}">View</asp:HyperLink>
</ItemTemplate>
<FooterStyle BackColor="#0061C1" />
<HeaderStyle BackColor="#0061C1" ForeColor="White" />
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:TemplateField>
</Columns>
</asp:GridView>
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
protected void Page_Load(object sender, EventArgs e)
{
MTMSService obj = new MTMSService();
DBAccess db = new DBAccess();
{
MTMSDTO objc = new MTMSDTO();
{
objc.TaskID = Convert.ToInt32(Session["TaskID"]);
DataSet rep = obj.GetReports(objc);
DataView Rprts = new DataView();
Rprts.Table = rep.Tables[0];
LblTaskName.Visible = true;
LblAssignBy.Visible = true;
LblDescription.Visible = true;
LblDueDate.Visible = true;
LblStatus.Visible = true;
LblPercentageComplete.Visible = true;
LblAssignTo.Visible = false;
}
}
}
stored procedure
ALTER PROCEDURE [dbo].[GetReports]
@TaskID int
AS
Select TaskName, DueDate, Description, AssignBy, Status, PercentageComplete
From dbo.Task
Where TaskID = @TaskID;