0


I was used a FormView to show data in my page :

        <asp:FormView ID="PFull" runat="server" >
    <ItemTemplate>
        <div class="post_con">
            <h4 class="post-headers"><asp:HyperLink ID="hprPTitle" runat="server" NavigateUrl='<%#Eval("PID","~/Paper.aspx?pid={0}")%>'><%#Eval("PTitle")%></asp:HyperLink></h4>
        </div>
    </ItemTemplate>
    </asp:FormView>

Bind form view :

public void ShowFullPaper(int id)
{
    DataTable dt = paper.ShowFullPaper(Convert.ToInt32(Request.QueryString["pid"]));
    PFull.DataSource = dt;
    PFull.DataBind();
}

Now, I want change title of page with text of that hyperlink with this :

protected void PFull_DataBound(object sender, EventArgs e)
{
    this.Title = ((HyperLink)PFull.FindControl("hprPTitle")).Text;
}

But That is not work. help me please...
Thanks.

kyrylomyr
  • 12,192
  • 8
  • 52
  • 79
Farzaneh Talebi
  • 835
  • 4
  • 22
  • 47

2 Answers2

2

Modify your aspx markup as below.

<asp:FormView ID="PFull" runat="server" >
    <ItemTemplate>
        <div class="post_con">
            <h4 class="post-headers"><asp:HyperLink ID="hprPTitle" runat="server" NavigateUrl='<%#Eval("PID","~/Paper.aspx?pid={0}")%>' Text='<%#Eval("PTitle")%>'></asp:HyperLink></h4>
        </div>
    </ItemTemplate>
</asp:FormView>

And then in your ItemDataBound event you could find it like below.

protected void PFull_DataBound(object sender, EventArgs e)
{
    this.Title = ((HyperLink)PFull.FindControl("hprPTitle")).Text;
}
Devraj Gadhavi
  • 3,541
  • 3
  • 38
  • 67
1

change design to--

<asp:FormView ID="PFull" runat="server" OnDataBound="PFull_DataBound" >
<ItemTemplate>
    <div class="post_con">
        <h4 class="post-headers"><asp:HyperLink ID="hprPTitle" runat="server" NavigateUrl='<%#Eval("Dosage","~/Paper.aspx?pid={0}")%>' Text='<%#Eval("PTitle")%>'></asp:HyperLink></h4>
    </div>
</ItemTemplate>
</asp:FormView>