Hi,
I add some checkboxes to an <ASP.Table>
I want execute a function whenever one of the checkboxes is clicked.
How can I do that.
This is how I was trying...
TableRow aRow = new TableRow();
CheckBox aBox = new CheckBox();
aBox.ID = "SomeID";
aBox.CheckedChanged += new EventHandler(aBox_CheckedChanged);
aBox.AutoPostBack = true;
TableCell aCell = new TableCell();
aCell.Controls.Add(aBox);
aRow.Cells.Add(aCell);
aTable.Rows.Add(aRow);
where aTable is a 'System.Web.UI.WebControls.Table'
Thnx for your help.
Scott Roberts - 12 Dec 2007 21:36 GMT
Works fine for me:
protected void Page_Load(object sender, EventArgs e)
{
TableRow aRow = new TableRow();
CheckBox aBox = new CheckBox();
aBox.ID = "SomeID";
aBox.CheckedChanged += new EventHandler(aBox_CheckedChanged);
aBox.AutoPostBack = true;
TableCell aCell = new TableCell();
aCell.Controls.Add(aBox);
aRow.Cells.Add(aCell);
Table1.Rows.Add(aRow);
}
private void aBox_CheckedChanged(object sender, EventArgs e)
{
Console.WriteLine((sender as CheckBox).Checked.ToString());
}
> I add some checkboxes to an <ASP.Table>
>
[quoted text clipped - 16 lines]
>
> Thnx for your help.