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 MPosted Mar 3, 2010, 4:13 AM
Amit ChoudharyPosted Mar 3, 2010, 7:59 AM
Jitendra PatelPosted Mar 3, 2010, 6:28 AM
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 ChoudharyPosted Mar 3, 2010, 4:21 AM
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.