Send a dataset to a view in MVC 2

1

PD: Lack of information: what I want to show in the gridview are only the data that I insert into the database from the excel I do not want to show ALL the records of this one. good afternoon community my question is the following it turns out that I did a file upload in MVC 2 (aspx) that reads me an excel and exports it to a DB from the view now my question is the following as I can show in a grid that dataset that I have created in the controller Excerpt from Code C #

 private void InsertExceldata(string fileepath, string filename)
    {
        string fullpath = Server.MapPath("/excelFolder/") + filename;
        ExcelConn(fullpath);
        string query = string.Format("Select * from[FP diario$]");
        string fecha = string.Format("Select * from[TCO$C4:C5]");
        string nombre = string.Format("Select * from[FP diario$B2:B500]");
        OleDbCommand Ecom = new OleDbCommand(query, Econ);
        OleDbCommand Efech = new OleDbCommand(fecha, Econ);
        OleDbCommand Enombre = new OleDbCommand(nombre, Econ);
        Econ.Open();
        DataSet ds = new DataSet();
        DataSet fech = new DataSet();
        DataSet nombreds = new DataSet();
        OleDbDataAdapter oda = new OleDbDataAdapter(query, Econ);
        OleDbDataAdapter odafech = new OleDbDataAdapter(fecha, Econ);
        OleDbDataAdapter odanombre = new OleDbDataAdapter(nombre, Econ);
        Econ.Close();
        oda.Fill(ds);
        odafech.Fill(fech);
        odanombre.Fill(nombreds);
        ds.Tables[0].Rows.RemoveAt(0);
        ds.Tables[0].AcceptChanges();
        DataTable dt = ds.Tables[0];
        DataTable df = fech.Tables[0];
        DataTable dn = nombreds.Tables[0];}

Aspx code

     <div class="col-lg-6 col-sm-6 col-12">
    <%using (Html.BeginForm("Mantenedor", "Mantenedor", FormMethod.Post, new { enctype = "multipart/form-data" }))
        {%>
    <h4>Factor de Penalización</h4>
    <div class="input-group">

        <input type="text" class="form-control" readonly>
        <label class="input-group-btn">
            <span class="btn btn-primary" style="right: 209px;">Seleccionar Archivo…
                <input type="file" name="file" id="file" style="display: none;" multiple="">
            </span>
        </label>


    </div>
    <div>
        <input type="submit" value="Subir PO.xls" class="btn btn-primary" style="margin-top: 1px;">
    </div>
    <% } %>
    <span class="help-block"></span>
</div>
<script>
    $(function () {

        // We can attach the 'fileselect' event to all file inputs on the page
        $(document).on('change', ':file', function () {
            var input = $(this),
                numFiles = input.get(0).files ? input.get(0).files.length : 1,
                label = input.val().replace(/\/g, '/').replace(/.*\//, '');
            input.trigger('fileselect', [numFiles, label]);
        });

        // We can watch for our custom 'fileselect' event like this
        $(document).ready(function () {
            $(':file').on('fileselect', function (event, numFiles, label) {

                var input = $(this).parents('.input-group').find(':text'),
                    log = numFiles > 1 ? numFiles + ' files selected' : label;

                if (input.length) {
                    input.val(log);
                } else {
                    if (log) alert(log);
                }

            });
        });

    });
</script>


<p>
    &nbsp;
</p>
    
asked by Joel Baez 07.05.2018 в 20:24
source

0 answers