Friends, I have a linkbutton inside a repeater's item templete and i want to access the link buttons text on the next page.I set the postbackurl to the next page.But when i use the page.PrevoiusPage.Findcontrol("lnkReport") on the 开发者_如何学Godestination page's code behind , I get a null value .These are the markups .Can anyone please help?
<asp:Content ID="Content2" ContentPlaceHolderID="cpmain" runat="Server">
<fieldset id="fsTrialAct"></fieldset>
<asp:Repeater ID="rptRepeater" runat="server">
<asp:LinkButton ID="lnkReport"
PostBackUrl="~/features/Reports/AdHocReportDetail.aspx"
runat="server"><%#Eval("AdhocBurstingReportName")%>
</asp:LinkButton></p>
</asp:Repeater>
</asp:Content>
You use master pages thus your repeater reside in Content Place Holder. What you need to do is find control of the Content Place Holder first before you find the repeater.
Example:
Control placeHolder = PreviousPage.Controls[0].FindControl("ContentPlaceHolder1");
TextBox SourceTextBox = (TextBox)placeHolder.FindControl("TextBox1");
if (SourceTextBox != null)
{
Label1.Text = SourceTextBox.Text;
}
I assume in your case, instead of creating TextBox you should create repeater object and use FindControl again to find the link.
精彩评论