Skip to content

Replies

0
zeppelin led
zeppelin led answered on May 26, 2014 5:19 AM

Well i didnt want to use Jquery to post data to the server , so I used MVC Helper to achieve what i wanted :

 @(Html.Infragistics().Combo()
                .InputName("EntityValue")
                    .ID("listingCombo")
                    .Width("270px")
                    //.DataSource(this.Model as IQueryable<COMMON.Models.ListingModel>)
                    .DataSourceUrl(Url.Action("ComboData"))
                    .ValueKey("EntityValue")
                    .TextKey("EntityName")
                    .DataBind()
                    .Render()
                )

so far so good . I am getting the value on my controller's action method.

0
zeppelin led
zeppelin led answered on May 19, 2014 10:41 AM

I have the following View:

@using (Html.BeginForm("Submit", "Dashboard", FormMethod.Post, new { @id = "form", @class = "form-horizontal" }))
{

@(Html.Infragistics().ComboFor(item=>item.EntityName)
.Width("270px")
//.DataSource(this.Model as IQueryable<COMMON.Models.ListingModel>)
.DataSourceUrl(Url.Action("ComboData"))
.ValueKey("EntityValue")
.TextKey("EntityName")
.DataBind()
.Render()
)

<input id="submitBtn" type="submit" value="Update" />

}

In Controller:

[HttpPost]
public ActionResult Submit(ListingModel listingModel)    //On submit click , it is looking for ActionResult Submit(),I want to call Submit(ListingModel listingModel)
{
// do something
}

on submit click I want to pass the model to my action method , but instead of getting model in parameter, the html form is looking for a paramterless action method which means it is not getting the model on post back. why is this happening.

0
zeppelin led
zeppelin led answered on May 19, 2014 9:56 AM

You mean to say that I cannot get the value of the combobox through the submit button of the form. What if I have a complex object that i want to pass to the action method when it is selected from the dropdown. Do i have to use Jquery and first create an object of it on client side. That would be a big problem.