ASP.NET 기초 강의실

시삽: 레드플러스 님 
게시판 이동:
 제목 : 동적으로 생성된 라디오 버튼의 값을 C#에서 받아오기
글번호: 318
작성자: 레드플러스
작성일: 2009/08/27 오전 10:22:00
조회수: 6866
파일: MultipleRadioButton.png (3 KB) / 전송수: 1710
MultipleRadioButton.png
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FrmMultipleRadioButton.aspx.cs"
    Inherits="MultipleRadioButton_FrmMultipleRadioButton" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    1번
        <asp:RadioButtonList ID="rdo1" runat="server" RepeatDirection="Horizontal">
            <asp:ListItem Value="A">A</asp:ListItem>
            <asp:ListItem Value="B">B</asp:ListItem>
            <asp:ListItem Value="C">C</asp:ListItem>
            <asp:ListItem Value="D">D</asp:ListItem>
        </asp:RadioButtonList>
    2번
        <asp:RadioButtonList ID="rdo2" runat="server" RepeatDirection="Horizontal">
            <asp:ListItem Value="A">A</asp:ListItem>
            <asp:ListItem Value="B">B</asp:ListItem>
            <asp:ListItem Value="C">C</asp:ListItem>
            <asp:ListItem Value="D">D</asp:ListItem>
        </asp:RadioButtonList>
        <asp:Button ID="btnSelect" runat="server" Text="선택" onclick="btnSelect_Click" />
        <asp:Label ID="lblDisplay" runat="server" Text="Label"></asp:Label>
    </div>
    </form>
</body>
</html>




using System;

public partial class MultipleRadioButton_FrmMultipleRadioButton : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnSelect_Click(object sender, EventArgs e)
    {
        string[] arr = new string[2];
        for (int i = 0; i < 2; i++)
        {
            arr[i] = Request.Form["rdo" + (i + 1).ToString()];
        }

        string results = "<br />선택한 값 : <br />";
        for (int i = 0; i < 2; i++)
        {
            results += arr[i] + "<br />";
        }
        this.lblDisplay.Text = results;
    }
}
 
이전 글   다음 글 삭제 수정 답변 글쓰기 리스트


관련 아티클 리스트
  제       목 파일 작성자 작성일 조회
이전글 속성(Property)을 사용해서 자바스크립트에서 C# 결과값 사용 - 레드플러스 2009-09-03 4478
현재글 동적으로 생성된 라디오 버튼의 값을 C#에서 받아오기 MultipleRadioButton.png(3 KB) 레드플러스 2009-08-27 6866
다음글 첫번째 GridView에서 선택한 값을 두번째 GridView로 옮기기 WebDataControl.zip(497 KB) 레드플러스 2009-08-19 4264
 
손님 사용자 Anonymous (손님)
로그인 Home