I have a C# ASP .net
web form with one panel having many controls like text boxes and drop downs in a tabular column. User is allowed to enter data in these controls and when Copy button is pressed, all the contents of this panel should be copied to another panel on the same page having exactly same controls and columns whose enabled property is set to false
I am only getting the option of doing it like below
eg:-
Protected void Button_click ()
{
Panel2.textbox1.Text = Panel1.textbox1.Text;
Panel2.textbox2.Text = Panel1.textbox2.Text;
...
...
...
Panel2.textbox30.Text = Panel1.textbox30.Text;
which causes lot many lines of code and i feel its just not the good approach. Could you suggest any other alternatives or is it the only way?
My markup looks like this
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm5.aspx.cs" Inherits="AjaxToolkitTrial.WebForm5" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table class="auto-style1">
<tr>
<td>
<asp:Panel ID="Panel1" runat="server">
<table class="auto-style1">
<tr>
<td>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Copy" />
</td>
</tr>
</table>
</asp:Panel>
</td>
<td>
<asp:Panel ID="Panel2" runat="server">
<table class="auto-style1">
<tr>
<td>
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:DropDownList ID="DropDownList2" runat="server">
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
<asp:TextBox ID="TextBox6" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</asp:Panel>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
Thanks in advance..