2
私はSQLデータベースに接続されたリストビューコントロールを持っていますが、各ページに表示されるアイテムを制限するデータページャを設定しました。Datapagerコントロールが5秒ごとに自動的にページを変更します
私はdatapagerを:visible = falseに設定しました。データページャを5秒ごとに自動的に変更する方法を知りたいと思います。
ご協力いただきありがとうございます。
私はSQLデータベースに接続されたリストビューコントロールを持っていますが、各ページに表示されるアイテムを制限するデータページャを設定しました。Datapagerコントロールが5秒ごとに自動的にページを変更します
私はdatapagerを:visible = falseに設定しました。データページャを5秒ごとに自動的に変更する方法を知りたいと思います。
ご協力いただきありがとうございます。
私は同じ問題を抱えていました。解決策は非常に簡単です。
最初の手順は、ページにDataPagerコントロールとTimerコントロールを含めることです。
<asp:DataPager ID="pager" runat="server" PagedControlID="listView" PageSize="10">
<Fields>
<asp:NumericPagerField ButtonType="Link" />
</Fields>
</asp:DataPager>
<asp:Timer ID="timer" runat="server" Interval="1000" OnTick="timer_Tick">
</asp:Timer>
次は、このコードを記述する必要があります。
protected void timer_Tick(object sender, EventArgs e) {
//Verify that the session variable is not null
if (Session["startRowIndex"] == null)
Session.Add("startRowIndex", 0);
//Create a variable to store the first record to show
int startRowIndex = Convert.ToInt32(Session["startRowIndex"]);
//Show from the first record to the size of the page
this.pager.SetPageProperties(startRowIndex, this.pager.MaximumRows, true);
//Increase the first record to display in the size of the page
startRowIndex += this.pager.MaximumRows;
//If the first record exceeds the total number of records, restart the count.
if (startRowIndex > this.pager.TotalRowCount) startRowIndex = 0;
Session["startRowIndex"] = startRowIndex;
}
そして、Page_Loadイベントにこのコードを配置:
protected void Page_Load(object sender, EventArgs e) {
//This session variable to control the record to show for each tick
if (!IsPostBack) Session.Add("startRowIndex", 0);
}
手遅れではない場合、私は、あなたが何かに役立つ願っています私の母国語ではないので、私の英語には申し訳ありません。
ご挨拶はチリです。
[タイマコントロール](http://msdn.microsoft.com/en-us/library/bb386404.aspx)を使用するか、[Javascript](http://www.mcfedries)を調べる必要があります。 com/JavaScript/timer.asp) –