this was an old query and i get the idea from it(
I need to take those Values to the controller, I would have to save them in parameters of type TiendaParametros together with the dates, after storing in parameters they will be sent to MetodoQuery(parameters) where the query will be made to return the query result and then load it in a pdf . If there is another way to do this exercise, I would appreciate any 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 StoreAction(StoreParameters parameters, string id) { LocalReport lr = new LocalReport(); string path = System.IO.Path.Combine(Server.MapPath("~/Reports"), "Frutas.rdlc"); if (System.IO.File.Exists(path)) { lr.ReportPath = path; } else { returnView("Index"); } ReportDataSource rd = new ReportDataSource("DTfruits", QueryMethod(parameters).Tables[0]); ReportParameter[] parameters = new ReportParameter[2]; lr.DataSources.Add(rd); string reportType = id; stringmineType; 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, outmineType, out encoding, out fileNameExtension, out stream, out warnings); return File(renderedBytes, mineType); }
This is my StoreParameters class:
public class StoreParameters { public DateTime StartDate { get; set; } public DateTime EndDate { get; set; } public int FruitCode { get; set; } }
Just rename your select to:
With this, your CodFruta property of your TiendaParametros model will come with the selected value.
Hi, I hope it helps you.
You declare in the controllers that you want the session to be open.
Your fruit model:
the view: