Note that there are some explanatory texts on larger screens.

plurals
  1. POhyperlink in grid view not populating values in another page when clicked
    primarykey
    data
    text
    <p>please help with this hyperlink thing.. i got a grid view where one of the column contains hyperlink say ViewDetails. upon clicking ViewDetails it should get navigate to another page called as Reports.aspx where the page should display the grid row value of selectd column in grid view in labels. i have used row data bound event .. im getting blank labels if i click the hyperlink . i have written stored procedure to get the row values. and im calling it through KEY.. its TaskID which is an auto generated column which is invisible. depending on the key value i need to display the row values. </p> <p>here are the codes </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="TaskID" HeaderText="SL No" Visible="False" ReadOnly="True"&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" Width="70px" ForeColor="#0061C1" Text="ViewDetails" NavigateUrl="Reports.aspx"&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>aspx.cs code </p> <pre><code> protected void GrdViewMyTasks_RowDataBound(object sender, GridViewRowEventArgs e) { 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>code in reports.aspx.cs</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(Request.QueryString["TaskID"]);// DataSet rep = obj.GetReports(); DataView Rprts = new DataView(); Rprts.Table = rep.Tables[0]; var table = rep.Tables[0]; if (table.Rows.Count &gt; 0) { LblTaskID.Text = rep.Tables[0].Rows[0]["TaskID"].ToString(); LblTaskName.Text = rep.Tables[0].Rows[0]["TaskName"].ToString(); LblDueDate.Text = rep.Tables[0].Rows[0]["DueDate"].ToString(); LblDescription.Text = rep.Tables[0].Rows[0]["Description"].ToString(); LblAssignBy.Text = rep.Tables[0].Rows[0]["AssignBy"].ToString(); LblStatus.Text = rep.Tables[0].Rows[0]["Status"].ToString(); LblPercentageComplete.Text = rep.Tables[0].Rows[0]["PercentageComplete"].ToString(); } else { } LblTaskName.Visible = true; LblAssignBy.Visible = true; LblDescription.Visible = true; LblDueDate.Visible = true; LblStatus.Visible = true; LblPercentageComplete.Visible = true; LblAssignTo.Visible = false; } } } </code></pre> <p>and this is my stored procedure</p> <pre><code> ALTER PROCEDURE [dbo].[GetReports] @TaskID int AS Select TaskName, DueDate, Description, AssignBy, Status, PercentageComplete, TaskID From dbo.Task Where TaskID = @TaskID; </code></pre> <p>please let me know where im goin wrong. im unable to get the perfect solution for this from past 1 week... its getting headache thing ..</p> <p>getting error "input string is not in correct format" at commented line of reports.cs file </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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