This is a migrated thread and some comments may be shown as answers.

[Solved] Combobox/DropDown value in Controller

7 Answers 176 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ashok
Top achievements
Rank 1
Ashok asked on 26 Apr 2011, 05:09 AM
We have Combobox/Dropdown control inside
@using(Html.BeginForm("Action1", "Controller")){
    ........search controls (text box, dropdown etc) ....
    <input type="submit" id="btnId" value="Submit" />
}


Controller:
[HttpPost]
public ActionResult Action1(SearchViewModel viewModel){
    ..... How to get Selected Dropdown value?
}

7 Answers, 1 is accepted

Sort by
0
nachid
Top achievements
Rank 1
answered on 26 Apr 2011, 08:00 AM
in your SearchViewModel, there should be a property with the same name as your Combobox/Dropdown control
MVC will automatically bind them togother
0
Atanas Korchev
Telerik team
answered on 26 Apr 2011, 08:51 AM
Hi Tejas,

In addition you can check this example which shows a working implementation.

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Ashok
Top achievements
Rank 1
answered on 26 Apr 2011, 03:20 PM
As shown in working implementation, I can't get value of Selected Value of Dropdown/Combobox in Controller. Any idea?
0
Atanas Korchev
Telerik team
answered on 27 Apr 2011, 09:57 AM
Hi Tejas,

 I do not understand what you mean. The linked example shows how to get the value of the combobox:

<%= Html.Telerik().ComboBoxFor(x => x.ProductID)

%>


[AcceptVerbs(HttpVerbs.Post)]
public ActionResult ClientValidation(ProductDto dto)
{
    if (ModelState.IsValid)
    {
        ViewData["productID"] = dto.ProductID;
    }
    return View(dto);
}

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Ashok
Top achievements
Rank 1
answered on 27 Apr 2011, 02:42 PM
I think I go the answer.. you are using List<product> to tie to Dropdown/Combobox. I am using SelectListItem. This may be the cause I am not getting value. Is there a way I can get SelectListItem in controller for a Dropdown/Combobox?
0
Atanas Korchev
Telerik team
answered on 27 Apr 2011, 03:23 PM
Hello Tejas,

I am sorry but I still do not understand what the problem is. Could you send us some sample code which we could look at?

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Ashok
Top achievements
Rank 1
answered on 27 Apr 2011, 03:25 PM
Hi Atanas,

I am in middle of some changes, if it doesn't work, I will send you sample.
Tags
ComboBox
Asked by
Ashok
Top achievements
Rank 1
Answers by
nachid
Top achievements
Rank 1
Atanas Korchev
Telerik team
Ashok
Top achievements
Rank 1
Share this question
or