Tarun Jaiswal

Tarun Jaiswal

  • NA
  • 9
  • 5.7k

How i can print Receipt of a Company in ASP.NET C#

Oct 23 2014 4:18 AM
How i can print Receipt of a Company in ASP.NET C#

Here in my case i have some 50-60 customer data available in database
and i want to print them in a form of Receipt.

i have already designed the receipt by using label controls in page load event but
on page load it only display last value fetched by database.

how i can print all customer details at once ?


private void printmethod()
        {
            string CS = System.Configuration.ConfigurationManager.ConnectionStrings["SocietyCS"].ConnectionString;
            using (SqlConnection con = new SqlConnection(CS))
            {
                SqlCommand cmd = new SqlCommand("Select * from tblmember", con);
                con.Open();
                SqlDataReader rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    lblIDs.Text = rdr.GetValue(1).ToString();
                    lblnames.Text = rdr.GetValue(3).ToString();
                    lblwings.Text = rdr.GetValue(4).ToString();
                    lblrooms.Text = rdr.GetValue(5).ToString();
                }
            }
        }


this code only show value of last database row,
i dnt know how to dynamically assign label and value so that it will print all details from database.


Thanks in Advance

Answers (3)