test3.aspx

 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test3.aspx.cs" Inherits="test3" debug="True" %>

<!DOCTYPE html>

<html>

<head>

<title></title>

</head>

<body>

<form id="form1" runat="server">

<table border="1">

<tr><td>姓名</td>

<td>電話</td>

<td>E-Mail</td>

<td>是否吃素?</td>

<tr><td><asp:TextBox ID="TextBox_Username1" runat="server"></asp:TextBox></td>

<td><asp:TextBox ID="TextBox_Tel1" runat="server"></asp:TextBox></td>

<td><asp:TextBox ID="TextBox_Email1" runat="server"></asp:TextBox></td>

<td><asp:RadioButtonList ID="RadioButtonList_1" runat="server" RepeatDirection="Horizontal">

<asp:ListItem Value="1">是</asp:ListItem>

<asp:ListItem Value="0">否</asp:ListItem>

</asp:RadioButtonList></td>

<tr><td><asp:TextBox ID="TextBox_Username2" runat="server"></asp:TextBox></td>

<td><asp:TextBox ID="TextBox_Tel2" runat="server"></asp:TextBox></td>

<td><asp:TextBox ID="TextBox_Email2" runat="server"></asp:TextBox></td>

<td><asp:RadioButtonList ID="RadioButtonList_2" runat="server" RepeatDirection="Horizontal">

<asp:ListItem Value="1">是</asp:ListItem>

<asp:ListItem Value="0">否</asp:ListItem>

</asp:RadioButtonList></td>

<tr><td><asp:TextBox ID="TextBox_Username3" runat="server"></asp:TextBox></td>

<td><asp:TextBox ID="TextBox_Tel3" runat="server"></asp:TextBox></td>

<td><asp:TextBox ID="TextBox_Email3" runat="server"></asp:TextBox></td>

<td><asp:RadioButtonList ID="RadioButtonList_3" runat="server" RepeatDirection="Horizontal">

<asp:ListItem Value="1">是</asp:ListItem>

<asp:ListItem Value="0">否</asp:ListItem>

</asp:RadioButtonList></td>

<tr><td><asp:TextBox ID="TextBox_Username4" runat="server"></asp:TextBox></td>

<td><asp:TextBox ID="TextBox_Tel4" runat="server"></asp:TextBox></td>

<td><asp:TextBox ID="TextBox_Email4" runat="server"></asp:TextBox></td>

<td><asp:RadioButtonList ID="RadioButtonList_4" runat="server" RepeatDirection="Horizontal">

<asp:ListItem Value="1">是</asp:ListItem>

<asp:ListItem Value="0">否</asp:ListItem>

</asp:RadioButtonList></td>

<tr><td><asp:TextBox ID="TextBox_Username5" runat="server"></asp:TextBox></td>

<td><asp:TextBox ID="TextBox_Tel5" runat="server"></asp:TextBox></td>

<td><asp:TextBox ID="TextBox_Email5" runat="server"></asp:TextBox></td>

<td><asp:RadioButtonList ID="RadioButtonList_5" runat="server" RepeatDirection="Horizontal">

<asp:ListItem Value="1">是</asp:ListItem>

<asp:ListItem Value="0">否</asp:ListItem>

</asp:RadioButtonList></td>

<tr><td><asp:TextBox ID="TextBox_Username6" runat="server"></asp:TextBox></td>

<td><asp:TextBox ID="TextBox_Tel6" runat="server"></asp:TextBox></td>

<td><asp:TextBox ID="TextBox_Email6" runat="server"></asp:TextBox></td>

<td><asp:RadioButtonList ID="RadioButtonList_6" runat="server" RepeatDirection="Horizontal">

<asp:ListItem Value="1">是</asp:ListItem>

<asp:ListItem Value="0">否</asp:ListItem>

</asp:RadioButtonList></td>

<tr><td><asp:TextBox ID="TextBox_Username7" runat="server"></asp:TextBox></td>

<td><asp:TextBox ID="TextBox_Tel7" runat="server"></asp:TextBox></td>

<td><asp:TextBox ID="TextBox_Email7" runat="server"></asp:TextBox></td>

<td><asp:RadioButtonList ID="RadioButtonList_7" runat="server" RepeatDirection="Horizontal">

<asp:ListItem Value="1">是</asp:ListItem>

<asp:ListItem Value="0">否</asp:ListItem>

</asp:RadioButtonList></td>

<tr><td><asp:TextBox ID="TextBox_Username8" runat="server"></asp:TextBox></td>

<td><asp:TextBox ID="TextBox_Tel8" runat="server"></asp:TextBox></td>

<td><asp:TextBox ID="TextBox_Email8" runat="server"></asp:TextBox></td>

<td><asp:RadioButtonList ID="RadioButtonList_8" runat="server" RepeatDirection="Horizontal">

<asp:ListItem Value="1">是</asp:ListItem>

<asp:ListItem Value="0">否</asp:ListItem>

</asp:RadioButtonList></td>

<tr><td><asp:TextBox ID="TextBox_Username9" runat="server"></asp:TextBox></td>

<td><asp:TextBox ID="TextBox_Tel9" runat="server"></asp:TextBox></td>

<td><asp:TextBox ID="TextBox_Email9" runat="server"></asp:TextBox></td>

<td><asp:RadioButtonList ID="RadioButtonList_9" runat="server" RepeatDirection="Horizontal">

<asp:ListItem Value="1">是</asp:ListItem>

<asp:ListItem Value="0">否</asp:ListItem>

</asp:RadioButtonList></td>

<tr><td><asp:TextBox ID="TextBox_Username10" runat="server"></asp:TextBox></td>

<td><asp:TextBox ID="TextBox_Tel10" runat="server"></asp:TextBox></td>

<td><asp:TextBox ID="TextBox_Email10" runat="server"></asp:TextBox></td>

<td><asp:RadioButtonList ID="RadioButtonList_10" runat="server" RepeatDirection="Horizontal">

<asp:ListItem Value="1">是</asp:ListItem>

<asp:ListItem Value="0">否</asp:ListItem>

</asp:RadioButtonList></td>

</table>

<asp:Button ID="Button1" runat="server" Text="儲存" OnClick="Button1_Click"/>

<br><br>

<asp:Label ID="Label99" runat="server" Text=""></asp:Label>

</form>

</body>

</html>

 

test3.aspx.cs

 

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

 

public partial class test3: System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

if (!Page.IsPostBack)

{

}        

}

 

protected void Button1_Click(object sender, EventArgs e)   //儲存

{

for (int i = 1; i <= 10; i++)

{

TextBox txtUsername = (TextBox)Page.FindControl("TextBox_Username" + i.ToString());

TextBox txtTel = (TextBox)Page.FindControl("TextBox_Tel" + i.ToString());

TextBox txtEmail = (TextBox)Page.FindControl("TextBox_Email" + i.ToString());

RadioButtonList buttonlist = (RadioButtonList)Page.FindControl("RadioButtonList_" + i.ToString());

Label99.Text += txtUsername.Text + "&nbsp;&nbsp;" + txtTel.Text + "&nbsp;&nbsp;" +  txtEmail.Text + "&nbsp;&nbsp;" +  buttonlist.SelectedValue + "<br>";

}

}

}

arrow
arrow
    全站熱搜

    adamschen9921 發表在 痞客邦 留言(0) 人氣()