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

how to get DropDownList view selected value in controller

2 Answers 264 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Amitkumar
Top achievements
Rank 1
Amitkumar asked on 08 Apr 2014, 02:18 PM

[HttpPost]
public ActionResult Submit(HttpPostedFileBase files,)
{
if (files != null && files.ContentLength > 0)
{
var filename = Path.GetFileName(files.FileName);
MemoryStream target = new MemoryStream();
files.InputStream.CopyTo(target);
byte[] data = target.ToArray();

//"Reconcile" is from DropDown1(Cabinate) and  "Microsoft" is DropDown2(Publisher)

CheckInDoc( "Reconcile", "Microsoft", filename , data);
 
}
return RedirectToAction("Result");
}





<form method="post" action='@Url.Action("Submit")' style="width:45%">
<h3>Cabinate</h3>
@(Html.Kendo().DropDownList()
.Name("Cabinate")
.DataTextField("Text")
.DataValueField("Value")
.Events(e => e.Change("change"))
.BindTo(new List<SelectListItem>() {
new SelectListItem() {
Text = "Selet Cabinate",
Value = "-1"
},
new SelectListItem() {
Text = "Reconcile",
Value = "1"
},
new SelectListItem() {
Text = "Discovery",
Value = "2"
}
})
.Value("-1")
)
<h3>Folder</h3>
@(Html.Kendo().DropDownList()
.Name("Folder")
.BindTo(new List<string>() { "Select Publisher", "Microsoft", "Telerik", "Redhate" })
)
 
<div class="demo-section">
@(Html.Kendo().Upload()
.Name("files")
)
<p>
<input type="submit" value="Submit" class="k-button" />
</p>
</div>
</form>

2 Answers, 1 is accepted

Sort by
0
Amitkumar
Top achievements
Rank 1
answered on 08 Apr 2014, 07:15 PM
Anyways finally I used
FormCollection to get the post data. Let me know if someone has better idea.
I am newbie

Thanks
0
Georgi Krustev
Telerik team
answered on 09 Apr 2014, 08:49 AM
Hello,

Did you try to add a string Cabinate parameter to the Submit Action method. This will tell the MVC framework to map the posted values to the method's parameters. The other option is to retrieve the posted values manually using the FormCollection, like you've already done.

Regards,
Georgi Krustev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
DropDownList
Asked by
Amitkumar
Top achievements
Rank 1
Answers by
Amitkumar
Top achievements
Rank 1
Georgi Krustev
Telerik team
Share this question
or