protected void BtnExport_Click(object sender, EventArgs e) { OmanFloatDAL OFDAL = new OmanFloatDAL(); OFDAL.ConnectionString = ConfigurationManager.ConnectionStrings["MySQLConn"].ToString(); List <OmanFloat> OFList = OFDAL.GetOmanFloat(null); var mem = new MemoryStream(); var writer = new StreamWriter(mem, Encoding.UTF8, 1024, true); var csvWriter = new CsvWriter(writer); csvWriter.Configuration.Delimiter = ","; csvWriter.WriteField("OrderNo"); csvWriter.WriteField("OrderDate"); csvWriter.WriteField("MemberName"); csvWriter.WriteField("PaymentstoOman"); csvWriter.WriteField("Totalcost"); csvWriter.WriteField("Deliveryfees"); csvWriter.WriteField("TotaCostwithDelivery"); csvWriter.WriteField("TotalRemainingAmount"); csvWriter.WriteField("Status"); csvWriter.WriteField("DeliveryDate"); csvWriter.WriteField("CardTypeandAmount"); csvWriter.WriteField("Quantity"); csvWriter.WriteField("Dateofpayment"); csvWriter.NextRecord(); int lenght = OFList.Count - 1; for (int i = 0; i <= lenght; i++) { csvWriter.WriteField(OFList[i].OrderNo); csvWriter.WriteField(OFList[i].OrderDate); csvWriter.WriteField(OFList[i].MemberName); csvWriter.WriteField(OFList[i].PaymentstoOman); csvWriter.WriteField(OFList[i].Totalcost); csvWriter.WriteField(OFList[i].Deliveryfees); csvWriter.WriteField(OFList[i].TotalCostwithDelivery); csvWriter.WriteField(OFList[i].TotalRemainingAmount); csvWriter.WriteField(OFList[i].Status); csvWriter.WriteField(OFList[i].DeliveryDate); csvWriter.WriteField(OFList[i].CardTypeandAmount); csvWriter.WriteField(OFList[i].Quantity); csvWriter.WriteField(OFList[i].Dateofpayment); csvWriter.NextRecord(); } writer.Flush(); var data = Encoding.UTF8.GetString(mem.ToArray()); Response.Clear(); Response.AddHeader("content-disposition", "attachment; filename=OmanFloat.csv"); Response.Charset = ""; Response.ContentType = "text/csv"; Response.Write(data.ToString()); Response.End(); }
private void GetOmanFloat(string orderno) { OmanFloatDAL OFDAL = new OmanFloatDAL(); OFDAL.ConnectionString = ConfigurationManager.ConnectionStrings["MySQLConn"].ToString(); List <OmanFloat> OFList = OFDAL.GetOmanFloat(orderno); gvOF.DataSource = OFList; gvOF.DataBind(); }
private void GetOmanFloat() { OmanFloatDAL OFDAL = new OmanFloatDAL(); OFDAL.ConnectionString = ConfigurationManager.ConnectionStrings["MySQLConn"].ToString(); List <OmanFloat> OFList = OFDAL.GetOmanFloat(null); gvOF.DataSource = OFList; gvOF.DataBind(); //lblTotalAmount.Text=OFList }