Thursday, March 10, 2005

Placing Radio buttons in Datagrid control

Here the challenge we faced was that, from a given set of radio buttons in datagrid, we can select only one radio button. This feature is for the purpose, to select a row from DataGrid. Radio buttons behave as a single group based on their GroupName property. When put inside DataGrid, DataGrid generates a unique name for each radio button. This causes each radio button to operate independently of others.

In order to solve the problem mentioned above, we create a template column and put a Label web control in it. In the ItemDataBound event of the DataGrid we wrote code that emits 'Input' element with type as Radio and set its Name attribute. This will display the grid with radio buttons in the column. You can select any one of the radio button at a time. This solved our requirement.

In order to retrieve the selected radio button, since we are not using RadioButton web control, we can not directly refer it as usual. Instead we can use ‘Request.Form’ collection. We can directly retrieve the selected radio button using this collection as in traditional ASP.

Programming at its best....

Comments:
sir,

i saw u r topic "Placing Radio buttons in Datagrid control" in blogspot.i am aware of the same situation only.could u please send me the sample code to my mail id.
Asp.Net Using Vb.Net

"karthikeyan_karur@rediffmail.com"

i am waiting for u reply.
 
Post a Comment

This page is powered by Blogger. Isn't yours?