반응형
닷넷2003버전에서 데이터그리드 사용시 라디오버튼에 그룹이 자동으로 
지정되기 때문에 (각각 고유의 그룹명으로 자동생성됨) 아래와 같은 과정을 통해서
라디오버튼컨트롤을 생성해주어야 한다.

①라디오버튼을 적용할 데이터그리드 필드를 아래와 같이 우선 정의한다.(aspx테그에추가)
<asp:TemplateColumn>
<ItemStyle HorizontalAlign="Center" Width="20px"></ItemStyle>
<ItemTemplate>
<asp:Literal runat="server" ID="cbcheck"></asp:Literal>
</ItemTemplate>
</asp:TemplateColumn>
②데이터그리드의 ItemDataBound이벤트에 아래와 같이 이벤트를 작성(cs폼에추가)
string radioFormat = "<input type=radio name='cbcheck' value='{0}' {1}>";
if( e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem 
    || e.Item.ItemType == ListItemType.SelectedItem )
{
DataRowView drv = e.Item.DataItem as DataRowView;
Literal cbcheck = e.Item.FindControl("cbcheck") as Literal;
cbcheck.Text = String.Format(radioFormat,e.Item.ItemIndex,"");
}

+ Recent posts