I'm working on Asp.net MVC3 application with KendoUI. Database is MySql.
Its a sample movie application.
This is my model:-
public int Movie_ID { get; set; }
public string Movie_Name { get; set; }
public Nullable<System.DateTime> Release_Date { get; set; }
public string Movie_Type { get; set; }
public string Movie_Cert { get; set; }
public string Movie_Poster { get; set; }
public string Movie_Budget { get; set; }
public bool Awards { get; set; }
This is the view:-
<h2>Add a Movie:-</h2>
<br/>
@using (Html.BeginForm("Create", "New_Movie",FormMethod.Post, new { id = "uploadForm", enctype = "multipart/form-data" }))
{
@Html.ValidationSummary(true)
<fieldset>
<label class="k-label">Movie Name:</label>
<div class="k-textbox">
@Html.TextBoxFor(m => m.Movie_Name)
</div>
<br/>
<br/>
<label class="k-label">Release Date:</label>
@(Html.Kendo().DatePickerFor(m => m.Release_Date)
.Name("Release_Date")
)
<br/>
<br/>
<label class="k-label">Movie Type:</label>
@(Html.Kendo().ComboBoxFor(m => m.Movie_Type)
.Name("Mov_Type")
.Placeholder("Select Type...")
.BindTo(new string[]
{"Action",
"Comedy",
"Documentary",
"Suspense Thriller"}
)
)
<label class="k-label">Movie Budget:</label>
@(Html.Kendo().DropDownListFor(m => m.Movie_Budget)
.Name("Budget")
.BindTo(new string[] {
"1 to 25 crores",
"26 to 50 crores",
"51 to 75 crores",
"above 76"
})
)
<input type="submit" name="submit" value="Submit" />
</fieldset>
}
Now when i submit this page to the controller create()
[HttpPost]
public ActionResult Create( movie_master movie_record)
{
using (var insert = new moviesEntities())
{
insert.movie_master.Add(movie_record);
insert.SaveChanges();
}
return RedirectToAction("Index");
}
the model object movie_record contains Movie_Type=null and Movie_Budget=null.
The Kendo datapicker returns the date value selected.
What am i doing wrong ? Please help me.
Its a sample movie application.
This is my model:-
public int Movie_ID { get; set; }
public string Movie_Name { get; set; }
public Nullable<System.DateTime> Release_Date { get; set; }
public string Movie_Type { get; set; }
public string Movie_Cert { get; set; }
public string Movie_Poster { get; set; }
public string Movie_Budget { get; set; }
public bool Awards { get; set; }
This is the view:-
<h2>Add a Movie:-</h2>
<br/>
@using (Html.BeginForm("Create", "New_Movie",FormMethod.Post, new { id = "uploadForm", enctype = "multipart/form-data" }))
{
@Html.ValidationSummary(true)
<fieldset>
<label class="k-label">Movie Name:</label>
<div class="k-textbox">
@Html.TextBoxFor(m => m.Movie_Name)
</div>
<br/>
<br/>
<label class="k-label">Release Date:</label>
@(Html.Kendo().DatePickerFor(m => m.Release_Date)
.Name("Release_Date")
)
<br/>
<br/>
<label class="k-label">Movie Type:</label>
@(Html.Kendo().ComboBoxFor(m => m.Movie_Type)
.Name("Mov_Type")
.Placeholder("Select Type...")
.BindTo(new string[]
{"Action",
"Comedy",
"Documentary",
"Suspense Thriller"}
)
)
<label class="k-label">Movie Budget:</label>
@(Html.Kendo().DropDownListFor(m => m.Movie_Budget)
.Name("Budget")
.BindTo(new string[] {
"1 to 25 crores",
"26 to 50 crores",
"51 to 75 crores",
"above 76"
})
)
<input type="submit" name="submit" value="Submit" />
</fieldset>
}
Now when i submit this page to the controller create()
[HttpPost]
public ActionResult Create( movie_master movie_record)
{
using (var insert = new moviesEntities())
{
insert.movie_master.Add(movie_record);
insert.SaveChanges();
}
return RedirectToAction("Index");
}
the model object movie_record contains Movie_Type=null and Movie_Budget=null.
The Kendo datapicker returns the date value selected.
What am i doing wrong ? Please help me.