TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
prabhu p
NA
181
114.5k
How to resolve the following error in mvc 4
Apr 17 2016 4:31 AM
Iam new to MVC I have problem in loading data in grid view
Iam getting error
"The best overloaded method match for 'System.Web.Helpers.WebGrid.WebGrid(System.Collections.Generic.IEnumerable<object>, System.Collections.Generic.IEnumerable<string>, string, int, bool, bool, string, string, string, string, string, string, string)' has some invalid arguments"
my controller class
public ActionResult ShowAllMobileDetails(mobileda MB)
{
DAL.DBdata objDB = new DAL.DBdata(); //calling class DBdata
MB.StoreAllData = objDB.SelectAllData();
return View(MB);
}
-------------------]
-------my model class
public class mobileda
{
public int MobileID { get; set; }
[Required(ErrorMessage = "Please Enter Mobile Name")]
[Display(Name = "Enter Mobile Name")]
[StringLength(50, MinimumLength = 3, ErrorMessage = "Mobile Name must be between 3 and 50 characters!")]
public string MobileName { get; set; }
[Required(ErrorMessage = "Please Enter MobileIMEno")]
[Display(Name = "Enter MobileIMEno")]
[MaxLength(100, ErrorMessage = "Exceeding Limit")]
public string MobileIMEno { get; set; }
[Required(ErrorMessage = "Please Enter Mobile Price")]
[Display(Name = "Enter Mobile Price")]
[DataType(DataType.Currency)]
public string mobileprice { get; set; }
[Required(ErrorMessage = "Please Enter Mobile Manufacured")]
[Display(Name = "Enter Mobile Manufacured")]
[DataType(DataType.Text)]
public string mobileManufacured { get; set; }
public DataSet StoreAllData { get; set; }
}
--------
--My DAL
public DataSet SelectAllData()
{
SqlConnection con = null;
string result = "";
DataSet ds = null;
try
{
con = new SqlConnection(ConfigurationManager.ConnectionStrings["mycon"].ToString());
SqlCommand cmd = new SqlCommand("Usp_InsertUpdateDelete", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@MobileID", 0); // i will pass zero to MobileID beacause its Primary .
cmd.Parameters.AddWithValue("@MobileName", null);
cmd.Parameters.AddWithValue("@MobileIMEno", null);
cmd.Parameters.AddWithValue("@mobileprice", 0);
cmd.Parameters.AddWithValue("@mobileManufacured", null);
cmd.Parameters.AddWithValue("@Query", 4);
con.Open();
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
ds = new DataSet();
da.Fill(ds);
return ds;
}
catch
{
return ds;
}
finally
{
con.Close();
}
}
----------
Myview
@{
ViewBag.Title = "ShowAllMobileDetails";
}
<!DOCTYPE html>
<html>
<head>
<title>WebgridSample</title>
<script src="../../Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
<style type="text/css">
.webGrid { margin: 4px; border-collapse: collapse; width: 500px; background-color:#FCFCFC;}
.header { background-color: #C1D4E6; font-weight: bold; color: #FFF; }
.webGrid th, .webGrid td { border: 1px solid #C0C0C0; padding: 5px; }
.alt { background-color: #E4E9F5; color: #000; }
.gridHead a:hover {text-decoration:underline;}
.description { width:auto}
.select{background-color: #389DF5}
</style>
</head>
<body>
<h2>ShowAllMobileDetails</h2>
@{
insertupdatedelete.Models.mobileda product = new insertupdatedelete.Models.mobileda();
}
@{
var grid = new WebGrid(Model, canPage: true, rowsPerPage: 5, selectionFieldName: "selectedRow",ajaxUpdateContainerId: "gridContent");
grid.Pager(WebGridPagerModes.NextPrevious);}
<div id="gridContent">
@grid.GetHtml(tableStyle: "webGrid",
headerStyle: "header",
alternatingRowStyle: "alt",
selectedRowStyle: "select",
columns: grid.Columns(
grid.Column("MobileID", format: (item) => item.GetSelectLink(item.Id)),
grid.Column("MobileName", " MobileName"),
grid.Column("MobileIMEno", "MobileIMEno"),
grid.Column("mobileprice", "mobileprice"),
grid.Column("mobileManufacured", "mobileManufacured")
))
</div>
</body>
</html>
Iam getting error on this line in view \\
var grid = new WebGrid(Model, canPage: true, rowsPerPage: 5, selectionFieldName: "selectedRow",ajaxUpdateContainerId: "gridContent");
can any one help me
Thanks
Reply
Answers (
1
)
Data Update
Host ASP.net MVC 5 wen App