I am facing follow error
The model item passed into the dictionary is of type 'ERP_APP.Models.BigbaleView', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[ERP_APP.Models.BigbaleView]
Model class
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
namespace ERP_APP.Models
{
public class BBDetailView
{
SqlConnection con = new SqlConnection("data source=SERVER1\\SQLEXPRESS;initial catalog=SilverProduction;integrated security=True;MultipleActiveResultSets=True;");
public List<BigbaleView> Selectalldata()
{
List<BigbaleView> custlist = null;
try
{
SqlCommand cmd = new SqlCommand("SP_ProducewiseBp", con);
cmd.CommandType = CommandType.StoredProcedure;
con.Open();
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
DataSet ds = new DataSet();
da.Fill(ds);
custlist = new List<BigbaleView>();
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
BigbaleView cobj = new BigbaleView();
cobj.Prdno = Convert.ToInt32(ds.Tables[0].Rows[i]["Prdno"].ToString());
cobj.Descriptionitem = ds.Tables[0].Rows[i]["Descriptionitem"].ToString();
cobj.Secnam = ds.Tables[0].Rows[i]["Secnam"].ToString();
custlist.Add(cobj);
}
return custlist;
}
catch
{
return custlist;
}
finally
{
con.Close();
}
}
}
}
Model class
public class BigbaleView
{
public List<SelectListItem> Catagory { get; set; }
public List<SelectListItem> Sections { get; set; }
public List<SelectListItem> ItemMasterFiles { get; set; }
public List<BigbaleView> ShowallBigBale { get; set; }
public int CodeItem { get; set; }
public int Prdno { get; set; }
public string Descriptionitem { get; set; }
public int SecID { get; set; }
public string Secnam { get; set; }
public int CID { get; set; }
public string CName { get; set; }
public ItemMasterFile item { get; set; }
public Section section { get; set; }
public Catagory category { get; set; }
public Probale bigbale { get; set; }
}
View
@model IEnumerable<ERP_APP.Models.BigbaleView>
@{
}
<div class="card">
<div class="card-header">
<div class="text-sm">
<div class="card-title">Item List</div>
</div>
</div>
<div class="card-body">
@Html.ActionLink("Create New", "CreaterEmployee", null, new { @class = "btn btn-primary" })
<hr />
@using (Html.BeginForm("BBDetail", "BigBale", FormMethod.Post))
{
<div class="form-horizontal">
<div class="form-group form-group-sm">
<div class="col-md-8">
@*<input name="start" type="date" id="datepicker" class="form-control" />*@
<input name="start" type="date" id="start" class="form-control" value="@Request["start"]" />
</div>
</div>
<div class="form-group form-group-sm">
<div class="col-md-8">
<input name="end" type="date" id="end" class="form-control" value="@Request["end"]" />
@*<input name="end" type="date" id="datepicker" class="form-control" />*@
</div>
</div>
<div class="form-group-sm">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Get" onclick="SubmitForm()" class="btn btn-default" /> <span> </span>
</div>
</div>
</div>
}
<table class="table table-striped my-4 w-100" id="datatable2">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.Descriptionitem)
</th>
<th>
<th>Action</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Descriptionitem)
</td>
<td>
@Html.ActionLink("Edit", "EditItem", new { codiitem = item.CodeItem }, new { @class = "btn btn-warning" }) |
@Html.ActionLink("Delete", "Delete", new { }, new { @class = "btn btn-danger" })
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
Controller
public ActionResult BBDetail()
{
BigbaleView objCustomer = new BigbaleView();
BBDetailView bbd = new BBDetailView(); //calling class DBdata
objCustomer.ShowallBigBale = bbd.Selectalldata();
return View(objCustomer);
}