protected void Button1_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-0ADOEDB\SQLDEV2019;Initial Catalog=WebApplication;Integrated Security=True");
SqlCommand com = new SqlCommand("Insert into Cust_Data values(@Name,@Gender, @Country, @State,@City,@Adress,@Email, @Contact)", con);
con.Open();
com.Parameters.AddWithValue("@Name", txtname.Text);
com.Parameters.AddWithValue("@Gender", rdogenderlist.SelectedValue);
com.Parameters.AddWithValue("@Country", txtcountry.Text);
com.Parameters.AddWithValue("@State", txtstate.Text);
com.Parameters.AddWithValue("@City", DropDownlist1.SelectedItem.Value);
com.Parameters.AddWithValue("@Adress",txtadress.Text);
com.Parameters.AddWithValue("@Email", txtemail.Text);
com.Parameters.AddWithValue("@Contact", txtcontact);
int i = com.ExecuteNonQuery();
if (i == 1)
{
txtname.Text = "";
rdogenderlist.SelectedValue = String.Empty;
txtcountry.Text = " ";
txtstate.Text = " ";
DropDownlist1.SelectedValue = String.Empty;
txtadress.Text = " ";
txtemail.Text = " ";
txtcontact.Text = " ";
}
con.Close();
}