-2
我想在asp.net web中實現一個計時器,在這段時間之後,按鈕的文本被改變。我在gridview中動態地創建了按鈕,並試着使用下面的代碼:如何在asp.net c#中實現計時器?
protected void Timer2_Tick(object sender, EventArgs e)
{
Label2.Text = "Panel refreshed at: " +
DateTime.Now.ToLongTimeString();
for(int i = 0; i< rowcount; i++)
{
Button button = new Button();
if (button.Text == "requested")
{
button.Text = "available";
}
}
}
但它不起作用。我怎麼解決這個問題?
要更改在GridView中創建的按鈕的文本,需要對該Button對象的引用,Button button = new Button()只是創建一個新的Button對象,該對象與GridView中先前創建的Button無關.. – Kevin