Search code examples
jqueryasp.netvisual-studio-2010asp.net-mvc-3-areas

applying Jquery autocomplete on "Edit" button with set of default values


I have a web application built in asp.net MVC3, VS2010. My website displays a table of data with a set of columns and rows. I have just one "Create new" option on the whole web page which creates a new row on the table. And I have "Edit" options on every row of the table data which allows the user to edit individual rows. Every row corresponds to different employee id. So, for example, I want to edit an employee id=120, I can click on a particular "Edit" button that is on the row with that employee id.

I could successfully apply autocomplete for the fields on "Create new" using Jquery UI. But for "Edit" option on every row of data, I could apply the same autocomplete logic but what it does is it doesn't display the default values of the fields on initial click of "Edit", it shows an empty textbox and on typing autocomplete comes into action.

To be more specific, by default without any autocomplete etc, when I click "Edit" on a particular row, it generally displays the fields with the default values. So, here when I am applying autcomplete I want to preserve the default values on those fields and then when user clicks on "Edit", he should be able to see the default values on all the fields and when he wants to change a particular field - he can click on that field and erase and start typing with autocomplete option.

Also, the default values on the fields for "Edit" are linqed from database not hardcoded. I am new to asp.net mvc, please help.


Solution

  • My view with autocomplete logic earlier wasn't wired to the model. I followed this to fix the issue http://blogs.msdn.com/b/stuartleeks/archive/2012/04/23/asp-net-mvc-amp-jquery-ui-autocomplete.aspx