Click here to Skip to main content
15,306,209 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more: , +
Hi all,
Im using this below code to retrieve the data of particular month and I am exporting this gridview data into pdf format.But grid view is displaying data but it is not exporting to pdf format.please help me...
Or I have to custom query to in sqldatasource so that I will bind sqldatasource to gridview to retrieve the data....
Please help me...


Code is:
C#
protected void FillBookingDataset()
     {
         DateTime firstDate = new DateTime(Calendar1.VisibleDate.Year,
      Calendar1.VisibleDate.Month, 1);
         DateTime lastDate = GetFirstDayOfNextMonth();
         dsBooking = GetCurrentMonthData(firstDate, lastDate);
     }

     protected DateTime GetFirstDayOfNextMonth()
     {
         int monthNumber, yearNumber;
         if (Calendar1.VisibleDate.Month == 12)
         {
             monthNumber = 1;
             yearNumber = Calendar1.VisibleDate.Year + 1;
         }
         else
         {
             monthNumber = Calendar1.VisibleDate.Month + 1;
             yearNumber = Calendar1.VisibleDate.Year;
         }
         DateTime lastDate = new DateTime(yearNumber, monthNumber, 1);
         return lastDate;
     }
     public override void VerifyRenderingInServerForm(Control control)
     {
         /* Verifies that the control is rendered */
     }


     protected DataSet GetCurrentMonthData(DateTime firstDate,
          DateTime lastDate)
     {
         DataSet dsMonth = new DataSet();
         ConnectionStringSettings cs;
         cs = ConfigurationManager.ConnectionStrings["BuckshawHomesConnectionString"];
         String connString = cs.ConnectionString;
         SqlConnection dbConnection = new SqlConnection(connString);
         dbConnection.Open();

         String query;
         query = "SELECT HouseID,BookingID,PersonTitle,fName,sName,Address1,Address2,Address3,City,Postcode,Country,Mobile,SpecialRequirements, CheckinDate,CheckoutDate,Price,AmountPaid,ReviewRequested,timeoutDate,IsPending,County FROM tblBooking " +
             " WHERE CheckinDate >= @firstDate AND CheckinDate < @lastDate";
         SqlCommand dbCommand = new SqlCommand(query, dbConnection);
         dbCommand.Parameters.Add(new SqlParameter("@firstDate",
             firstDate));
         dbCommand.Parameters.Add(new SqlParameter("@lastDate", lastDate));

         SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(dbCommand);
         sqlDataAdapter.Fill(dsMonth);

         //ASPxGridView1.DataSourceID = "SqlDataSourceMonth";
         ASPxGridView1.DataSource = dsMonth;
         ASPxGridView1.DataBind();
         dbConnection.Close();
         //try
         //{
         //    sqlDataAdapter.Fill(dsMonth);
         //}
         //catch { }
         return dsMonth;

     }
Posted
Updated 9-Mar-14 20:56pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900