티스토리 뷰
Repeater 안에 RadioButton을 넣을 경우..
실행해보면 다 따로논다. GroupName을 줘도 따로논다.
리피터를 실행 후 소스보기를 클릭해서 보면
각 Row마다 앞에 있는 ctl101.. ctl102.. 이렇게 증가되어 있다.
해결방법은 아래와같이
function SetUniqueRadioButton(nameregex, current) {
re = new RegExp(nameregex);
for (i = 0; i < document.forms[0].elements.length; i++) {
elm = document.forms[0].elements[i]
if (elm.type == 'radio') {
if (re.test(elm.name)) {
elm.checked = false;
}
}
}
current.checked = true;
}
Repeater_ItemDataBound에 아까 만들어 놓은 함수를 등록시켜주면 된다.
protected void rptPortfolios_ItemDataBound(object sender,
RepeaterItemEventArgs e)
{
if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType
!= ListItemType.AlternatingItem)
return;
RadioButton rdo = (RadioButton)e.Item.FindControl("RadioButton1");
string script =
"SetUniqueRadioButton('Repeater1.*rdoGroupName',this)";
rdo.Attributes.Add("onclick", script);
}
출처 : http://www.codeguru.com/csharp/csharp/cs_controls/custom/article.php/c12371/ASPNET-Tip-Using-RadioButton-Controls-in-a-Repeater.htm'프로그래밍 > ASP.NET' 카테고리의 다른 글
| Repeater Cell meage [ 리피터 셀병합 rowspan] (0) | 2012.04.25 |
|---|---|
| Repeater 에서 Header / Footer 템플릿 아이템 찾기 (리피터 FindContorl) (0) | 2012.04.25 |
| window.open & showModalDialog 창에서 버튼 누르면 계속 새창뜰때 해결방법 (0) | 2012.04.25 |
| ASP.NET 에서 자바스크립트 사용하는 방법 (0) | 2012.04.23 |
| Analysys Service(Cube)에 접근 해서 MDX쿼리로 데이터 가져오기. (0) | 2012.04.19 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- css3
- 저장프로시저
- SVG
- Ajax
- jQuery
- 프로시저
- Mobile
- JavaScript
- html5
- 자바스크립트
- grid
- Style
- WCF
- jquery chart
- workbook
- Chart
- IE
- 제이쿼리
- 셀렉터
- json
- CSS
- JS
- ASP.NET
- jQuery Mobile
- Excel
- radius
- drag&drop
- rowspan
- MSSQL
- WebApi
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 |
글 보관함