Click here to Skip to main content
13,147,689 members (29,453 online)
Rate this:
Please Sign up or sign in to vote.
Hi guys,

I have just started out with ASP.NET MVC3/4 and I have hit my first wall. I have a model class and a view that is strongly typed to it and obviously a controller. This view has a WebGrid that defines several columns that are bound to the model and 2 date columns (text boxes basically), i.e. Start Date and End Date that are not part of the model class. Finally, there is a ActionLink that when clicked talks to the controller by passing the id of the corresponding record.

Heres where I am stuck now, i also need to pass the start and end dates to the controller but I just can't figure out how to access the date values from the text boxes. I am using jQuery DatePicker widget to select a date in those text boxes but unlike regular ASP.NET there seems to be no way to just do a "txtStartDate.Text" or do a FindControl in a templated column.

My View markup looks like so:

@model IEnumerable<Models.BusinessObject1>
    var mvcgrid = new WebGrid(Model);    
<script type="text/javascript">
    $(document).ready(function () {
<div id="Grid">
    @mvcgrid.GetHtml(columns: mvcgrid.Columns(
                                              mvcgrid.Column("BOName", "Name"),
                                              mvcgrid.Column(null, "Start Date", format: (item) => Html.TextBox("txtStartDate")),
                                              mvcgrid.Column(null, "End Date", format: (item) => Html.TextBox("txtEndDate")),
                                              mvcgrid.Column(format: (item) => Html.ActionLink("Test","Check",new{selectedid =item.ID, startdate = ??, enddate = ??}))))

I know this sounds pretty MVC101-ish, but I have looked quite a lot and couldn't find something that would help me, may be I haven't looked enough so if anyone can help me with this it will be awesome.

Posted 9-Jan-13 0:34am
Updated 9-Jan-13 0:35am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.170915.1 | Last Updated 9 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100