Sunday, December 05, 2004

RadioButton in ASP.NET DataGrid

This one is really tricky. Today i was developing an asp.net datagrid and need to have a radiobutton for each row in datagrid, so the user can select a single row. It seems we can't group the radiobuttons even with GroupName property :-( And all my googling went into vain as it seems there is awful lot of code out there to fix this.

I fixed the issue with the following cool and simple code (Thanks Njeri). In the aspx page i used the following code

<input type="radio" id="RadioButtonCountry" name="RadioButtonCountry" value="<%#((System.Data.DataRowView)Container.DataItem)["Country"] %>" >

No comments: