[DataGrid tip] adding radiobutton to the DataGrid template column is a single choice.

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.