Click here to Skip to main content
15,892,575 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
It is such that I have a drop down and I some information that I should throw into the database,

Right now gives me this one error:

The name 'ddlRoles' does not exist in the current context
My code: - brugere.fk_role is what I need to get "going" to the database.

KontoController.cs

C#
brugere.Fk_role = Convert.ToInt32(ddlRoles);


Opret.cshtml

C#
@Html.DropDownList("ddlRoles",
new SelectList(Model.Roles, "Id", "Name"), "Vælg",
new { @class = "form-control input-lg" })


How can it be that it will take "my" value into kontocontroller.cs

It is such that I must have the value from the drop down into the database so I will only have spoken out and looked over / into the database
Posted
Comments
Michael_Davies 25-Jul-15 2:23am    
dllRoles is a dropdown, you are passing the control to be converted to int32 (Convert.ToInt32(ddlRoles)), you need to test that dllRoles has a selected item then pass the selected items's value (dllroles.SelectedItem.ToString) to be converted to int32.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900