Hi,
I am new in MVC Archicture.
Please Help me,
How to get DropDownlist value in MVC in ASP.Net?
I have bind dropdown with Name and ID but i can't get it's value when
page is post back.
When I select Name then it's Id value is get and bind Data (like Gridview).
Thanks In Advance,
Jitendra Patel
Loading

Lalit MRank #1,186 · 1.5K reputationPosted Mar 2, 2010, 11:13 PM EST
Amit ChoudharyRank #145 · 15.8K reputationPosted Mar 2, 2010, 11:21 PM EST
check out following articles:
http://stackoverflow.com/questions/1898407/getting-selectedvalue-back-from-a-dropdown-in-asp-net-mvc-c-using-entity-frame
http://simplelifeuk.wordpress.com/2009/09/21/display-selected-value-with-html-dropdownlist-in-asp-net-mvc/
Hope it helps you.
Jitendra Patel138 reputationPosted Mar 3, 2010, 1:28 AM EST
Thanks to Help me,
I got easy solution.
I have used javascript in the javascrip.
I have put my code
function GetDDLValue()
{
if (window.document.getElementById("DDLName").selectedIndex != 0) {
var id = window.document.getElementById("DDLName").selectedIndex;
window.location.href="Home/Search/" + id;
}
}
AND in Button click event this function call.
Thanks,
Jitendra Patel
Amit ChoudharyRank #145 · 15.8K reputationPosted Mar 3, 2010, 2:59 AM EST