最终,我正在尝试将分页文本(1 2 3等)更改为返回的每条记录的年份。 (2010年2011年2012年)。
我已经在数据绑定PreRender事件上输入了代码。我可以让它循环好,直到我更改PageIndex以获取持有年份的Label的值,此时我收到此错误:堆栈不足以继续安全地执行程序。这可能是因为调用堆栈上的函数太多或堆栈上的函数占用太多堆栈空间。
ASPX
<asp:FormView ID="fvRptHeader" runat="server" DataSourceID="odsRptHeader"
AllowPaging="True" DataKeyNames="ReportId" HeaderText="Annual Reports"
OnDataBound="fvRptHeader_DataBound" OnPreRender="fvRptHeader_PreRender">
<PagerTemplate>
//TODO: Figure out the linking
<a href="#"><asp:Label ID="lbl_pageNum" runat="server" /></a>
</PagerTemplate>
<ItemTemplate>
....Code
</itemTemplate>
</formview>
ASPX.CS
protected void fvRptHeader_DataBound(object sender, EventArgs e)
{
FormViewRow pagerRow = fvRptHeader.TopPagerRow;
Label pageNum = (Label)pagerRow.Cells[0].FindControl("lbl_pageNum");
if (pageNum != null)
{
string s_rowValue = "";
for (int i = 0; i < fvRptHeader.PageCount; i++)
{
fvRptHeader.PageIndex = i; //Gives Error: Insufficient stack to continue executing the program safely. This can happen from having too many functions on the call stack or function on the stack using too much stack space.
Label lbl_year = (Label)fvRptHeader.Row.FindControl("lblRptYearDescription");
s_rowValue += lbl_year.Text + i.ToString();
}
pageNum.Text = s_rowValue;
}
}