我用一個FormView顯示在我的網頁數據:
如何在FormView中獲取超鏈接的文本?
<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>
綁定表單視圖:
public void ShowFullPaper(int id)
{
DataTable dt = paper.ShowFullPaper(Convert.ToInt32(Request.QueryString["pid"]));
PFull.DataSource = dt;
PFull.DataBind();
}
現在,我想改變網頁的標題與該超鏈接的文本這樣的:
protected void PFull_DataBound(object sender, EventArgs e)
{
this.Title = ((HyperLink)PFull.FindControl("hprPTitle")).Text;
}
但就是不行。請幫我...
謝謝。
這是什麼回報? –
可能的重複 - http://stackoverflow.com/questions/6105634/cant-find-control-in-formview –