Note that there are some explanatory texts on larger screens.

plurals
  1. POgrid view row contains hyperlink and upon clicking it should display values o that particular row in another page
    text
    copied!<p>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) .</p> <p>please help me out. so far i have tried this.</p> <p>this is my grid view </p> <pre><code> &lt;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" &gt; &lt;Columns&gt; &lt;asp:BoundField DataField="Gen_ID" HeaderText="SL No" ReadOnly="True" Visible="False"&gt; &lt;FooterStyle BackColor="#0061C1" /&gt; &lt;HeaderStyle BackColor="#0061C1" HorizontalAlign="Center" VerticalAlign="Middle" /&gt; &lt;ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" /&gt; &lt;/asp:BoundField&gt; &lt;asp:TemplateField HeaderText="Task Name"&gt; &lt;ItemTemplate&gt; &lt;asp:Label ID="TaskName" runat="server" Font-Names="Verdana" Font-Size="X-Small" Height="24px" Text='&lt;%# Eval("TaskName")%&gt;' Width="70px"&gt;&lt;/asp:Label&gt; &lt;/ItemTemplate&gt; &lt;FooterStyle BackColor="#0061C1" /&gt; &lt;HeaderStyle BackColor="#0061C1" ForeColor="White" /&gt; &lt;ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" /&gt; &lt;/asp:TemplateField&gt; &lt;asp:TemplateField HeaderText="Due Date"&gt; &lt;ItemTemplate&gt; &lt;asp:Label ID="DueDate" runat="server" Font-Names="Verdana" Font-Size="X-Small" Height="20px" Width="70px" Text='&lt;%# Eval("DueDate"," {0:dd/MM/yyyy}")%&gt;' DataFormatString="{0:dd/MM/yyyy}"&gt;&lt;/asp:Label&gt; &lt;/ItemTemplate&gt; &lt;FooterStyle BackColor="#0061C1" /&gt; &lt;HeaderStyle BackColor="#0061C1" ForeColor="White" /&gt; &lt;ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" /&gt; &lt;/asp:TemplateField&gt; &lt;asp:TemplateField HeaderText="Description"&gt; &lt;ItemTemplate&gt; &lt;asp:Label ID="Description" runat="server" Font-Names="Verdana" Font-Size="X-Small" Height="20px" Width="90px" Text='&lt;%# Eval("Description")%&gt;'&gt;&lt;/asp:Label&gt; &lt;/ItemTemplate&gt; &lt;FooterStyle BackColor="#0061C1" /&gt; &lt;HeaderStyle BackColor="#0061C1" ForeColor="White" /&gt; &lt;ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" /&gt; &lt;/asp:TemplateField&gt; &lt;asp:TemplateField HeaderText="Assign By"&gt; &lt;ItemTemplate&gt; &lt;asp:Label ID="AssignBy" runat="server" Font-Names="Verdana" Font-Size="X-Small" Height="20px" Width="90px" Text='&lt;%# Eval("AssignBy")%&gt;'&gt;&lt;/asp:Label&gt; &lt;/ItemTemplate&gt; &lt;FooterStyle BackColor="#0061C1" /&gt; &lt;HeaderStyle BackColor="#0061C1" ForeColor="White" /&gt; &lt;ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" /&gt; &lt;/asp:TemplateField&gt; &lt;asp:TemplateField HeaderText="Status"&gt; &lt;ItemTemplate&gt; &lt;asp:Label ID="Status" runat="server" Font-Names="Verdana" Font-Size="X-Small" Height="20px" Width="90px" Text='&lt;%# Eval("Status")%&gt;'&gt;&lt;/asp:Label&gt; &lt;/ItemTemplate&gt; &lt;FooterStyle BackColor="#0061C1" /&gt; &lt;HeaderStyle BackColor="#0061C1" ForeColor="White" /&gt; &lt;ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" /&gt; &lt;/asp:TemplateField&gt; &lt;asp:TemplateField HeaderText="% Complete"&gt; &lt;ItemTemplate&gt; &lt;asp:Label ID="PercentageComplete" runat="server" Font-Names="Verdana" Font-Size="X-Small" Height="20px" Width="50px" Text='&lt;%# Eval("PercentageComplete")%&gt;'&gt; &lt;/asp:Label&gt; &lt;/ItemTemplate&gt; &lt;FooterStyle BackColor="#0061C1" /&gt; &lt;HeaderStyle BackColor="#0061C1" ForeColor="White" /&gt; &lt;ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" /&gt; &lt;/asp:TemplateField&gt; &lt;asp:TemplateField HeaderText="View Details"&gt; &lt;ItemTemplate&gt; &lt;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}"&gt;View&lt;/asp:HyperLink&gt; &lt;/ItemTemplate&gt; &lt;FooterStyle BackColor="#0061C1" /&gt; &lt;HeaderStyle BackColor="#0061C1" ForeColor="White" /&gt; &lt;ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" /&gt; &lt;/asp:TemplateField&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; </code></pre> <p>this is my code behind for grid view on row data bound </p> <pre><code> if (e.Row.RowType == DataControlRowType.DataRow) { HyperLink ViewDetails = e.Row.FindControl("ViewDetails") as HyperLink; ViewDetails.NavigateUrl = "Reports.aspx?TaskID=" + e.Row.Cells[0].Text; } </code></pre> <p>here is my code behind or reports.aspx where the details of the grid view should be displayed</p> <pre><code> 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; } } } </code></pre> <p>stored procedure </p> <pre><code> ALTER PROCEDURE [dbo].[GetReports] @TaskID int AS Select TaskName, DueDate, Description, AssignBy, Status, PercentageComplete From dbo.Task Where TaskID = @TaskID; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload