DJ메탈짱™의 Free Style

[ASP.NET] DataGrid 안에 라디오버튼 한개만 선택하게 본문

일(job)/MS(Microsoft)

[ASP.NET] DataGrid 안에 라디오버튼 한개만 선택하게

뽀&쏭 2015. 12. 4. 12:46


DataGrid 안에 라디오버튼 한개만 선택하게

 

// 콜백목록에 있는 라디오버튼을 하나만 클릭되도록 함.

// 작성자최보현(bhchoi@00db.co.kr)

// 작성일: 2010/12/04

functionSelectOne(rdo,gridName)

{

/* Getting an array of all the "INPUT" controls on the form.*/

all = document.getElementsByTagName("input");

for(i=0;i

{

if(all[i].type=="radio") /*Checking if it is a radio button*/

{

/*I have added '__ctl' ASP.NET adds '__ctl' to all the controls of DataGrid.*/

varcount=all[i].id.indexOf(gridName+'__ctl');

if(count!=-1)

{

all[i].checked=false;

}

}

}

rdo.checked=true/* Finally making the clicked radio button CHECKED */

}

 

<asp:TemplateColumn>

<HeaderStyleWidth="5%">

<ItemStyleHorizontalAlign="Center">

<ItemTemplate>

<input type="radio" runat="server" id="rdo" onclick="SelectOne(this,'dgList')" VALUE="rdo" NAME="RadioGroup" />

</ItemTemplate>

</asp:TemplateColumn>

--> dgList : DataGrid ID

 

http://www.codeproject.com/KB/aspnet/DATAGRID_WITH_RADIOBUTTON.aspx