我寫在asp.net的web應用程序, 在後面的代碼,我有這樣的代碼:使事件的多個按鈕,並知道被點擊了哪個按鈕
foreach(UserDetails _UD in m_TeachersDetailsList)
{
Button button = new Button();// a Button control
button.Text = "click";
button.ID = "SelectedTeacher";
TableCell tableCell = new TableCell();// a Cell control
tableCell.Controls.Add(button);
TableRow tableRow = new TableRow();
tableRow.Cells.Add(tableCell); // a table row
TableSearchResult.Rows.Add(tableRow); // a table that had been created in the aspx
}
我怎樣才能讓一個事件,當你點擊按鈕時,你將會看到一個功能, 以及如何知道哪個按鈕被點擊並帶我進入我的功能。 謝謝。
先試一下。 – 2012-02-01 17:04:58
你試圖用相同的ID創建多個控件,我不認爲它會工作,你試過嗎? – 2012-02-01 17:06:10
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.button.click.aspx應該讓你去... – Chris 2012-02-01 17:06:11