it will be better to provide me complete example ,will take time to approach on you level
You have to understand code is the tools forum member use to communicate. If the code is unclear, incomplete, and does not follow standard coding patterns then we cannot communicate efficiently. This is why I recommend learning MVC fundamentals and MVC standard coding patterns. We can speak the same coding language if you follow standards.
I tried my best to create an example based on your code. Unfortunately, your code is incomplete, unclear, does not follow standard coding patterns. The flow does not make a lot of sense or there are bits missing which would clarify the intent. Therefore the code example below which is based on your code technically works but is nonsensical.
URL
https://localhost:44321/Bigbale/index/?start=2023-01-01&end=2023-04-01
Model
public class BigbaleView
{
[Key]
public int Prdno { get; set; }
public int CodeItem { get; set; }
public string Descriptionitem { get; set; }
public string Secnam { get; set; }
}
Your data access
public class BBDetailView
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["defaultConnection"].ConnectionString);
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();
}
}
}
Controller
public class BigbaleController : Controller
{
// GET: Bigbale/?start=2023-01-01&end=2023-04-01
public ActionResult Index(string start, string end)
{
BBDetailView DataAccess = new BBDetailView();
List<BigbaleView> data = DataAccess.Selectalldata();
return View(data);
}
[HttpPost]
public ActionResult BBDetail(string start, string end)
{
ViewBag.Start = start;
ViewBag.End = end;
return View();
}
}
Index View
@model List<MvcIdentity.Models.BigbaleView>
@{
ViewBag.Title = "Index";
}
<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="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"]" />
</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[0].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>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
<script>
function SubmitForm() {
return;
}
</script>
}
BBDetail View
@{
ViewBag.Title = "BBDetail";
}
<h2>BBDetail</h2>
<div>@ViewBag.Start</div>
<div>@ViewBag.End</div>