How can i save the data which we got from one table of database to another table. Actually i want first to get data from first table using DROPDOWN and then save the data (i.e.Employee ID and Employee name) which we got in dropdown to another table of the database.
CS Code:
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(!
this
.IsPostBack)
{
this
.PopulateDropDownList();
}
}
private
void
PopulateDropDownList()
{
string
constr = ConfigurationManager.ConnectionStrings[
"ConString"
].ConnectionString;
using
(SqlConnection con =
new
SqlConnection(constr))
{
using
(SqlCommand cmd =
new
SqlCommand(
"SELECT FirstName,EmployeeID FROM Employees"
, con))
{
using
(SqlDataAdapter da =
new
SqlDataAdapter(cmd))
{
con.Open();
DataSet ds =
new
DataSet();
da.Fill(ds);
this
.ddlEmployees.DataTextField =
"FirstName"
;
this
.ddlEmployees.DataValueField =
"EmployeeID"
;
this
.ddlEmployees.DataSource = ds;
this
.ddlEmployees.DataBind();
this
.ddlEmployees.Items.Insert(0,
new
System.Web.UI.WebControls.ListItem(
" --Select Please-- "
,
"0"
));
}
}
}
}