Kianoush Kianoush - 6 months ago 29
ASP.NET (C#) Question

insert text of dropdown in database

I've created a register page .

This my table for register in database :

enter image description here

This my table for education :

enter image description here

i fill education tabel and fil dropdown by that value .

code for


public static class Education
public static IEnumerable<SelectListItem> GetEducationList()
using (AllameHelliDB db = new AllameHelliDB())
var List = (from a in db.Tbl_Educations
orderby a.EduID
select new SelectListItem { Text = a.EduName, Value = a.EduID.ToString() });
return List.ToList();



@Html.LabelFor(model => model.MotherEducation)
new { @class = "form-control" })

I need add
from table Education add in
tabel Regsiter
. When i insert data return null .

How resolve this problem ?


Your drop own is bound to the the Paye field, so this is the field that will get the EduID, if you want to get the text EduName for the selected option then you can do it from the Action itself, by reading the Paye property and retrive the Education object with this ID then fill the MotherEducation.

Or you can add another drop down list for the MotherEducation field but you will have to make both the Text and Value = EduName