Tuesday, February 14, 2012

Motivational Songs


itanee shaktee humei denaa daataa, man kaa wishwaas kamajor ho naa
hum chale nek raste pe hum se, bhoolakar bhee koee bhool ho naa

Monday, February 13, 2012

Combined multiple pdf into one pdf in c#

A datatable with columns at run time


01 public class Customer
02    {
03        private string _firstName;
04        private string _lastName;
05        private string _email;
06 
07        public string FirstName
08        {
09            get { return _firstName; }
10            set { _firstName = value; }
11        }
12 
13        public string LastName
14        {
15            get { return _lastName; }
16            set { _lastName = value; }
17        }
18 
19        public string FullName
20        {
21            get { return _firstName + " " + _lastName; }
22        }
23 
24        public string Email
25        {
26            get { return _email; }
27            set { _email = value; }
28        }
29      }








------------------------------------------------
 //DataGrid1.DataSource=GetCustomers();
// DataGrid1.DataBind();
DataTable dt=new DataTable();
dt=GetCustomers();
-------------------------------------------------
09        private List<Customer> GetCustomers()
10        {
11            List<Customer> customers = new List<Customer>();
12 
13            for (int i = 1; i <= 20; i++)
14            {
15                Customer customer = new Customer();
16                customer.FirstName = "FirstName" + i;
17                customer.LastName = "LastName" + i;
18                customer.Email = "Email" + i;
19                customers.Add(customer);
20            }
21 
22            return customers;
23        }







Export to pdf from a file in asp.net

      Response.Clear();
      Response.Buffer = true;
      Response.ContentType = "application/pdf";
      Response.AddHeader("Content-Type", "application/pdf");
      Response.AddHeader("Content-Disposition", "inline; filename=Test.pdf");
 
      FileStream fs = new FileStream(filename, FileMode.Open);
      long fileSize = fs.Length;
      byte[] bBuffer = new byte[System.Convert.ToInt32(fileSize)];
      fs.Read(bBuffer, 0, System.Convert.ToInt32(fileSize));
      fs.Close();
      Response.BinaryWrite(bBuffer);
      Response.Flush();
      Response.Close();

Export to pdf/excel/word/csv/txt from DataTable/DataGrid in asp.net

Note: When you export the GridView to PDF using the below code it will seem that the export is taking place correctly but when you try to open the file you will realize that the file is corrupted. Although this particular code works when exporting to Excel or Text files this code will fail when exporting to PDF files. To export GridView to PDF we will need to use a third party library ITextSharp:  http://funwithcomputers-nishant.blogspot.in/2011/11/export-gridview-to-pdf-using-itextsharp.html   (or)  http://highoncoding.com/Articles/483_Exporting_GridView_to_PDF_Document.aspx

DataGrid dtaFinal = new DataGrid();
dtaFinal.DataSource = dsReports.Tables[0];
dtaFinal.DataBind();

dtaFinal.HeaderStyle.ForeColor = System.Drawing.Color.White;
dtaFinal.HeaderStyle.BackColor = System.Drawing.Color.DarkGray;
dtaFinal.ItemStyle.BackColor = System.Drawing.Color.White;
dtaFinal.AlternatingItemStyle.BackColor = System.Drawing.Color.AliceBlue;


//---Create the File---------
Response.Buffer = true;
Response.ClearContent();
Response.ClearHeaders();

//---For PDF uncomment the following lines----------
//Response.ContentType = "application/pdf";
//Response.AddHeader("content-disposition", "attachment;filename=FileName.pdf");

//---For MS Excel uncomment the following lines----------
//Response.ContentType = "application/vnd.ms-excel";
//Response.AddHeader("content-disposition", "attachment;filename=FileName.xls");

//---For MS Word uncomment the following lines----------
//Response.ContentType = "application/vnd.word";
//Response.AddHeader("content-disposition", "attachment;filename=FileName.doc");

//---For CSV uncomment the following lines----------
//Response.ContentType = "text/csv";
//Response.AddHeader("content-disposition", "attachment;filename=FileName.csv");

//---For TXT uncomment the following lines----------
//Response.ContentType = "text/plain";
//Response.AddHeader("content-disposition", "attachment;filename=FileName.txt");


EnableViewState = false;

StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);

//---Renders the DataGrid and then dumps it into the HtmlTextWriter Control
dtaFinal.RenderControl(hw);

//---Utilize the Response Object to write the StringWriter to the page
Response.Write(sw.ToString());
Response.Flush();
Response.Close();
Response.End();

Thursday, February 9, 2012

Steps to do for Education Developement



1) Teacher should be interacted with student during teaching. He should not be like that come in the class room, give the lecture on a lesson, his duty over. He should do questionnaire with student. Student should not only listen. Student should ask some question or at least give the answer of any particular question which already taught in previous study. Teacher should not make boring class (or) one-way communication.


2) Teacher should not focus to complete the syllabus. He should not set in the mind that at the end he need to cover syllabus only. His focus should be how much students learning from him? Which I am teaching, is it helpful to student in career prospective(not only exam prospective)?

Teacher should sum up at the end of class that you learn these thing today.