Thursday, September 15, 2005

You can bind to RadioButtonLists too...

Having messed around for a good part of yesterday with trying to bind some values to a RadioButtonList control and failing miserably, I suddenly realised (after a quick check on MSDN) just how simple it really is.


// Set the properties of the radio button list.

rbl.DataSource = results.Tables[0].DefaultView;
rbl.DataTextField = "Name";
rbl.DataValueField = "ID";
rbl.DataBind();

So much wasted time, but a lesson learnt. Next time I'll consider that databinding might exist, before I come up with some crazy scheme involving Literals...

Fixes to common .NET problems, as well as information on .NET features and solutions to common problems that are not language-specific.

Fixes to common .NET problems, as well as information on .NET features and solutions to common problems that are not language-specific.

Z