I am making a report with a stored procedure that has 3 entries in it, one is the amount, date, option, and on my page it has 3 input entries to enter and when you press export an excel file is downloaded, the problem is that it shows me an error "Error converting the value of the parameter from DropDownList to String". I would like you to help me please
protected void ExportExcel(object sender, EventArgs e) { string constr = ConfigurationManager.ConnectionStrings["con"].ConnectionString; string query = "COMISION_DIC16"; //string query = "SELECT TOP 10 codigomoneda, idcredito, numerocredito FROM credito..credito;"; // query += "SELECT TOP 10 idorigencredito, segmentotasa, segmentocartera FROM credito..credito;"; using (SqlConnection con = new SqlConnection(constr)) { using (SqlCommand cmd = new SqlCommand(query)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("TP", SqlDbType.VarChar, 30).Value = txtTC.Text; cmd.Parameters.Add("Fecha_FDM", SqlDbType.VarChar, 30).Value = txtFecha_FDM.Text; cmd.Parameters.Add("OPC", SqlDbType.VarChar, 30).Value = OPC; using (SqlDataAdapter sda = new SqlDataAdapter()) { cmd.Connection = con; sda.SelectCommand = cmd; using (DataSet ds = new DataSet()) { sda.Fill(ds); //Set Name of DataTables. ds.Tables[0].TableName = "idcredito"; ds.Tables[1].TableName = "numerocredito"; using (XLWorkbook wb = new XLWorkbook()) { foreach (DataTable dt in ds.Tables) { //Add DataTable as Worksheet. wb.Worksheets.Add(dt); } //Export the Excel file. Response.Clear(); Response.Buffer = true; Response.Charset = ""; Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; Response.AddHeader("content-disposition", "attachment;filename=Cuadro_1_dic16.xlsx"); using (MemoryStream MyMemoryStream = new MemoryStream()) { wb.SaveAs(MyMemoryStream); MyMemoryStream.WriteTo(Response.OutputStream); Response.Flush(); Response.End(); } } } } }