Click here to Skip to main content
15,885,878 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to get the selected Id of DDL in MVC i am not using Html helpers to generate Dropdownlist but simple <select></select>

C#
Id = Request.Form["ddl1"].ToString();

It is not working for me.I am trying to get the Id from View and passing the Id to same View having another Dropdownlist

C#
foreach (System.Data.DataRow dr in Class.Getddl2(Id).Rows)


Getddl2 is a method in my class and i am passing that Id to ddl.

This whole code is in View and not in controller or Class.

please note that i am requesting the Id when i reload the page using Ajax.
Posted
Updated 16-Jul-15 22:29pm
v5

1 solution

Ids are not submitted with the form data so you can't get them server-side, only the name and value are available. If you want the id you'll need to find some way of passing it in a hidden field or something.
 
Share this answer
 

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



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