htmltable\checkbox

  • Thread starter Thread starter gh
  • Start date Start date
G

gh

I have a HtmlTable with an asp.net checkbox in the cells of column 4.
Only 1 checkbox can be checked at a time. I know how to loop through
the html table, but not sure how to see if a checkbox is checked and how
to uncheck it. I would like to do this in the on click event of an
asp.net button. Does anyone have sample code for this?

Thanks
 
gh,

inside the onclick event maybe something like this? Make sure that the
checkboxes are readonly by default.

Button[] buttons = new Button[] { but1, but2, but3 };

int checkedIndex = 0;

for (int i = 0; i < buttons.length; i++)
{
Button currentBut = buttons;
if (currentBut.Checked)
{
nextcheckedIndex = i++;
if (nextcheckedIndex >= buttons.length) nextcheckedIndex = 0;
buttons[nextcheckedIndex].Checked = true;
currentBut.Checked = false;
break;
}
}



--
Ward Bekker
"Asp.Net Discussions for the Professional Developer"
http://www.dotnettaxi.com

"Free .Net 2.0 C# to/from VB.Net Code Converter"
http://www.dotnettaxi.com/Tools/Converter.aspx
 
Would you consider using RadioButtons with GroupName property set? That will
ensure only one button is clicked.

Eliyahu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top