Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
500
Persist value of igCombo on postback (Maintain state of igCombo)
posted

Hello, 

I need to persist the selected value of my igCombo on postback when the submit button is clicked, I am using Asp.Net MVC

I have followed this approach but I am getting null in my int[] comboProducts parameter in my [HttpPost] method. please see the code below, Why am I getting null in the action method parameter.

-----------------------------------

In my Controller:

[HttpGet]
public ActionResult ComboTest()
{
return View();
}

[HttpPost]
public ActionResult ComboTest(int[] comboProducts)       // I am getting null here
{
ViewBag.ProductComboSelectedItems = comboProducts; 
return View();
}

------------------------------------

In my View:


@using (Html.BeginForm())
{
@(Html.Infragistics().Combo()   /* @Html.Infragistics().Combo("comboProducts") does not work and throws object null reference exception */
.InputName("comboProducts")
.ID("comboProducts")
.Width("270px")
.DataSourceUrl(Url.Action("ComboData"))
.MultiSelection(ComboMultiSelection.On)
.SelectedValues(ViewBag.ProductComboSelectedItems)
.ValueKey("EntityName")
.TextKey("EntityName")
.DataBind()
.Render()
)


}

-----------------------------------------------------------------------

Please point out where am i going wrong. I cannot seem to understand why am I getting null as parameter.

Parents
  • 4275
    Verified Answer
    Offline posted

    Hello, Omer.

    Thank you for using our products and I hope that my answer will help you resolve that case.

    You can try the ComboFor method, which is supposed to be used, when you want to send Combo value to the server. Please check this sample and see if it works for you. I will wait for your feedback.

    Best regards,

    Nikolay Alipiev

Reply Children
No Data