This was an old query and I get the idea out of it (
I need to take those Values to the controller, I would have to save them in Parameters of the ShopParameters type along with the dates, after storing them in parameters they will be sent to the QueryMethod (parameters) where the query will be made to return the query result and then upload it in a pdf. if there is another way to do that exercise I would appreciate all information, thanks )
This is my view:
@model Tienda.net.Controllers.Reportes.TiendaParametros
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
@using (Html.BeginForm("TiendaAction", "ControllerTienda", new { id = "PDF" }, FormMethod.Post))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<fieldset>
<div class="editor-label">
@Html.LabelFor(model => model.FechaInicio)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.FechaInicio)
@Html.ValidationMessageFor(model => model.FechaInicio)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.FechaFinal)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.FechaFinal)
@Html.ValidationMessageFor(model => model.FechaFinal)
</div>
<div class="row">
<div class="col-md-3">
Colegio<br />
<select name="singleSelect"class="form-control">
<option value="1">manzana</option>
<option value="3">tomate</option>
<option value="8">zandia</option>
<option value="9">melon</option>
<option value="4">naranja</option> <!-- quiero que toda esta informacion me cargue en una DropDownList -->
<option value="5">limon</option>
<option value="2">mora</option>
<option value="7">frutilla</option>
</select>
</div>
</div>
<p>
<br />
<input type="submit" value="Create" />
</p>
</fieldset>
}
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
this is my controller
public ActionResult TiendaAction(TiendaParametros parametros, string id) { LocalReport lr = new LocalReport(); string path = System.IO.Path.Combine(Server.MapPath("~/Reportes"), "Frutas.rdlc"); if (System.IO.File.Exists(path)) { lr.ReportPath = path; } else { return View("Index"); } ReportDataSource rd = new ReportDataSource("DTfrutas", MetodoConsulta(parametros).Tables[0]); ReportParameter[] parameters = new ReportParameter[2]; lr.DataSources.Add(rd); string reportType = id; string mineType; string encoding; string fileNameExtension; string deviceInfo = "" + "" + id + "" + "8.5in" + "11in" + "0,787402in" + "0,787402in" + "0,787402in" + "0,787402in" + ""; Warning[] warnings; string[] streams; byte[] renderedBytes; renderedBytes = lr.Render( reportType, deviceInfo, out mineType, out encoding, out fileNameExtension, out streams, out warnings); return File(renderedBytes, mineType); }
this my ShopParameters class:
public class TiendaParametros { public DateTime FechaInicio { get; set; } public DateTime FechaFinal { get; set; } public int CodFruta { get; set; } }