private void textBox1_Leave(object sender, EventArgs e) { textBox2.Text = textBox1.Text; } private void textBox2_Enter(object sender, EventArgs e) { textBox2.Text = textBox1.Text; }
foreach (ListItem li in DrpList.Items) { DropDownList1.Items.Add(li); }
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm3.aspx.cs" Inherits="Insert_data_confirmation.WebForm3" %> <!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>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br /> <asp:DropDownList ID="DropDownList1" runat="server"> </asp:DropDownList> <asp:DropDownList ID="DropDownList2" runat="server"> </asp:DropDownList> <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" /> </div> </form> </body> </html> using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; namespace Insert_data_confirmation { public partial class WebForm3 : System.Web.UI.Page { protected void Button1_Click(object sender, EventArgs e) { TextBox2.Text = TextBox1.Text; DropDownList2.Items.Add(DropDownList1.SelectedValue); } protected void Page_Load(object sender, EventArgs e) { DropDownList1.Items.Add("select"); if (!IsPostBack) { DropDownList1.Items.Add("a"); DropDownList1.Items.Add("b"); DropDownList1.Items.Add("c"); } } } }
If this post helps you mark it as answer Thanks
Login to post response