jQuery Date picker not setting value

Hello, I am pretty new to mvc sites and trying to figure out the jQuery date picker in a web grid. I am able to put the date picker into my layout so it renders to all pages:

   
 <link href="~/Content/themes/base/jquery-ui.min.css" rel="stylesheet" />
    <script src="~/Scripts/jquery-2.2.4.min.js"></script>
    <script src="~/Scripts/jquery-ui-1.12.1.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $(".datePicker").datepicker({
                dateFormat: "dd-mm-yyyy"
            });

        })
    </script>

Open in new window


and can add the class to my webgrid, and it does display but I do not get an date value entered into the field when i select a date from the calendar:

webGrid.Column("Calendar_Dt", "Calendar Date", format: @<text>  <span class="display-mode"> <label id="lblCalendar_Dt">@item.Calendar_Dt</label> </span> <input type="text" id="Calendar_Dt"  class="edit-mode datePicker" /></text>, style: "col2Width")

Open in new window


What I am doing incorrectly here?

Thank you for any help you can provide.

edit:
It seems that the datepicker does not like the names of the input being the same and that is why if you update row 5 the value is placed in the row 1 textbox.  Is there a way to refer back to the webgrid row by index value or some other unique name such as name="@item.id"?
JustinAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

JustinAuthor Commented:
I am able to get the date function to update each row of the webgrid if i change it to:

webGrid.Column("Calendar_Dt", format: (item) => Html.TextBox("Calendar_Dt[" + (rowNum -1).ToString() + "].Calendar_Dt", (object)item.Calendar_Dt, new { @class = "datePicker"})),

Open in new window


but as soon as i try to wrap that in <span></span> tags to show or hid that section such as


webGrid.Column("Calendar_Dt", "Calendar_Dt", @<text>  <span class="display-mode"> <label id="lblCalendar_Dt">@item.Calendar_Dt</label> </span> <span class="edit-mode">format: (item) => Html.TextBox("Calendar_Dt[" + (rowNum -1).ToString() + "].Calendar_Dt", (object)item.Calendar_Dt, new { @class = "datePicker"})</span></text>)

Open in new window


it breaks. I still feel like im doing this wrong, im sure this is a common thing to do, add a calendar to a webgrid, i much be missing something very simple.
0
Vijaya KumarCommented:
0
JustinAuthor Commented:
Thank you Vijaya, that was pretty close to what I was trying to do. The only sad point is that method does not allow inline editing via ajax, its kinda  large form submit.
I ended up not using webgrid so i can keep ajax
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JustinAuthor Commented:
no answer for question provided
0
Jon SnowCommented:
Good Post. Also check Free Movie Sites l  Free Movie Sites HD
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET MVC

From novice to tech pro — start learning today.