i have one dropdownlist this value coming from another table so in this dropdown selected value insert into another table
<div class="col-lg-4">
<fieldset class="form-group">
@Html.LabelFor(model => model.CompanytypeID, new { @class = "form-label semibold" })
@Html.DropDownList("CompanyType", null, "--- Select CompanyType Name ---", new { @class = "select2-arrow" })
@Html.ValidationMessageFor(model => model.CompanytypeID, "", new { @style = "color:red" })
</fieldset>
</div>
public void CompanyType_Bind()
{
DataSet ds = dDSP.Get_CompanyType();
List<SelectListItem> companylist = new List<SelectListItem>();
foreach (DataRow dr in ds.Tables[0].Rows)
{
companylist.Add(new SelectListItem { Text = dr["CompanyType"].ToString(), Value = dr["CompanytypeID"].ToString() });
}
ViewBag.CompanyType = companylist;
}
public DataSet Get_CompanyType()
{
SqlCommand cmd = new SqlCommand("Select * From UserType", constr);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
return ds;
}