2012-10-31 61 views
0

MyPage.aspx後:更新文本框的值呈現

<asp:TextBox ID="txtPageCount" runat="server" EnableViewState="true" ></asp:TextBox> 
<rc:ReportControl id="ReportControl1" runat="server" /> 

ReportControl.ascx:

<div> 
      <rsweb:ReportViewer ID="ReportViewer1" runat="server" CssClass="ReportViewer" AsyncRendering="false" 
       OnPreRender="RptViewer_PreRender" EnableViewState="true" Width="100%" PageCountMode="Actual" 
       WaitMessageFont-Size="1.2em" ShowToolBar="true" Visible="true" 
       InteractiveDeviceInfos="(Collection)"> 
       <LocalReport></LocalReport>   
      </rsweb:ReportViewer> 

</div> 

後報告處理(RptViewer_PreRender),在Render事件MyPage.aspx,我更新值的txtPageCount

protected override void Render(HtmlTextWriter writer) 
{ 
    base.Render(writer); 
    TextBox pageCount = new TextBox(); 
    pageCount = (TextBox)RtDialysisSummary.FindControl("txtPageCount"); 

    pageCount.Text = Convert.ToString(ReportViewer1.TotalPages); 
} 

textbox的值沒有更新。

回答

1

嘗試更新值調用base.Render(writer);像下面

protected override void Render(HtmlTextWriter writer) 
{ 
    TextBox pageCount = new TextBox(); 
    pageCount = (TextBox)RtDialysisSummary.FindControl("txtPageCount"); 

    pageCount.Text = Convert.ToString(ReportViewer1.TotalPages); 
    base.Render(writer); 
} 
2

你確保你能獲得在mypage.aspx的渲染事件的正確之前PAGECOUNT? 因爲據我所知,呈現事件的mypage.aspx將出現在你的ascx控件的呈現事件之前,所以pagecount的值將會更老。

+0

謝謝。你是對的。 – mike44