【发布时间】:2009-10-14 10:52:26
【问题描述】:
我最近更改了我的网络应用程序上的连接方式,现在我遇到了一些我不明白的事情。
我有一个页面,它在 Page_Load 中调用一个名为“ItemGet”的函数,当第一个转发器 (Repeater1) 中没有数据时,它可以正常工作。当我单击使用不同数据重新加载页面的按钮时(我知道中继器中有数据),连接会在同一个中继器(中继器 1)之后自动关闭。问题在于,在 (RepeaterTopTen) 之后还有另一个中继器需要相同的连接。我在调用该函数后立即手动关闭了连接,但至少我需要连接在所有函数期间保持打开状态。
你们有谁知道它自己关闭的原因以及我能做些什么来防止它在这个时候关闭?
代码如下:
private void ItemsGet(string csCategory, string csTimeFrame)
{
DataSet data;
if (csCategory == null)
{
data = m_database.GetPost(Tools.GetPostLang(), Session["TimeFrame"].ToString());
Page.Title = m_database.GetTranslation(509);
}
else
{
data = m_database.GetPost(Convert.ToInt32(csCategory), Tools.GetPostLang(), Session["TimeFrame"].ToString());
Page.Title = m_database.GetTranslation(508) + m_database.GetCategoryName(Convert.ToInt32(csCategory));
}
// Populate the repeater control with the Items DataSet
PagedDataSource objPds = new PagedDataSource();
objPds.DataSource = (DataView)(data.Tables[0].DefaultView);
// Indicate that the data should be paged
objPds.AllowPaging = true;
// Set the number of items you wish to display per page
objPds.PageSize = 5;
// Set the PagedDataSource's current page
if (CurrentPage != 0)
objPds.CurrentPageIndex = CurrentPage;
else
objPds.CurrentPageIndex = 0;
lblCurrentPage.Text = m_database.GetTranslation(423) + (CurrentPage + 1).ToString() + m_database.GetTranslation(422) + objPds.PageCount.ToString();
// Disable Prev or Next buttons if necessary
btnPrev.Enabled = !objPds.IsFirstPage;
btnNext.Enabled = !objPds.IsLastPage;
Repeater1.DataSource = objPds;
Repeater1.DataBind();
DataSet dataTopTen = m_database.GetTopTenUser();
RepeaterTopTen.DataSource = dataTopTen;
RepeaterTopTen.DataBind();
}
【问题讨论】:
标签: asp.net connection repeater