나는이 문제에 심하게 붙어있어 도움이된다면 고맙겠습니다! 사용자가 버튼을 클릭하여 더 많은 행을 추가 할 수있는 페이지를 만들어야합니다. 예를 들어 첫 번째 행에는 2 개의 텍스트 상자 (이름 및 생년월일)가 있고 두 번째 행에는 '행 추가'버튼이 있습니다. 사용자가 "행 추가"버튼을 클릭하면 첫 번째 행이 복제되고 반복되어야하지만 사용자는 5 행을 초과하여 추가 할 수 없습니다. 나중에 모든 정보를 SQL 테이블에 저장해야합니다. 이것이 C#에서 어떻게 달성 될 수 있습니까?버튼 클릭으로 텍스트 상자의 행 추가
예제 ASP.NET을 첨부하고 있습니다. 아무도 저를 도울 수 있습니까?
추신 : 저는 이미 "How to : 표 웹 서버 컨트롤에 행과 셀을 동적으로 추가"를 읽었습니다. 그러나 그것은 저에게 효과적이지 않습니다.
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Testing Adding Rows</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Table ID="Table1" runat="server" width="400" style="border:[none][0]; border-color:White; border-style:hidden">
<asp:TableRow ID="TableRow1" runat="server">
<asp:TableCell runat="server" nowrap="nowrap" Width= "70">
<asp:Label ID="nameLabel" runat="server" Text="Your Name" Font-Size="X-Small"></asp:Label>
</asp:TableCell>
<asp:TableCell runat="server" nowrap="nowrap" Width= "100">
<asp:TextBox ID="tb_name" runat="server" Font-Size="Smaller"></asp:TextBox>
<asp:RequiredFieldValidator ID="nameValidator" runat="server" ControlToValidate="tb_name" Font-Size="Smaller">*</asp:RequiredFieldValidator>
</asp:TableCell>
<asp:TableCell runat="server" nowrap="nowrap" Width= "70">
<asp:Label ID="dateLabel" runat="server" Text="Birthdate" Font-Size="Smaller" ></asp:Label>
</asp:TableCell>
<asp:TableCell runat="server" Width= "100">
<asp:TextBox ID="tb_date" runat="server" Font-Size="Smaller"></asp:TextBox>
<asp:RequiredFieldValidator ID="dateValidator" runat="server" ControlToValidate="tb_date" Font-Size="Smaller">*</asp:RequiredFieldValidator>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow ID="TableRow2" runat="server">
<asp:TableCell runat="server" align="left" Width= "100">
<asp:Button ID="addRow" runat="server" Height="22px" Text="Add Row"
ToolTip="Click to add another row" onclick="ButtonAddRow_Click" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow ID="TableRow3" runat="server">
<asp:TableCell runat="server" bordercolor="#FFFFFF"> </asp:TableCell>
<asp:TableCell runat="server" align="left" nowrap="nowrap" bordercolor="#FFFFFF">
<asp:Label ID="msg" runat="server" ForeColor="Red" Font-Size="Smaller"></asp:Label>
<asp:ValidationSummary ID="LogonValidationSummary" HeaderText="All the fields (*) are required." DisplayMode="SingleParagraph"
Font-Italic="true" ShowSummary="True" EnableClientScript="true" runat="server" Font-Size="Smaller"/>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow ID="TableRow4" runat="server">
<asp:TableCell ID="TableCell10" runat="server" bordercolor="#FFFFFF"> </asp:TableCell>
<asp:TableCell ID="TableCell11" runat="server" align="left" bordercolor="#FFFFFF">
<asp:Button ID="ButtonSubmit" runat="server" Height="22px" Text="Submit" Width="79px" onclick="ButtonSubmit_Click" />
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</div>
</form>
</body>
</html>
@Pranay 예, 나는 확실히 그렇게 할 것입니다. btw, GridView 컨트롤 사용에 대한 아이디어가 마음에 들었습니다. – AlwaysANovice
도움을 주신 모든 분들께 감사드립니다! 그러나, 나는 여전히 행에서 모든 정보를 수집하고 SQL 테이블에 저장해야 할 부분에 붙어있어, 아무도 도와 줄 수 있니? – AlwaysANovice