Sourcecode: testsingleselect.rar
Write down JavaScript first:<Script Language="Javascript">
VaR Flag = 0 ;
VaR Lastobj;
Function Cancelselect (OBJ ){
If (Flag = 0 )
{
Lastobj = OBJ;
Flag + = 1 ;
}
Else
{
If (Lastobj. ID ! = OBJ. ID ){
Lastobj. Checked = False ;
Lastobj = OBJ;
}
}
}
</ Script >
Add radiobutton to the template column and activate javascript:
< Itemtemplate >
< ASP: radiobutton ID = "Rbselect" Onclick = "Javascript: cancelselect (this );" Runat = "Server" > </ ASP: radiobutton >
</ Itemtemplate >
After Code To obtain the selected radiobutton Dim Demogriditem As Datagriditem
For Each Demogriditem In Grdemployees. Items
Dim Myradiobutton As Radiobutton = Ctype (Demogriditem. cells ( 0 ). Controls ( 1 ), Radiobutton)
If Myradiobutton. Checked = True Then
Myradiobutton. Checked = False
' Get select radiobutton
End If
Next
Of course, there are some good methods.ArticleReprinted on my Bolg.Problems caused by adding radiobutton to the DataGrid template Column
Codeproject: How to group radiobuttons