Monday, November 9, 2009

NOW, here is a true INDIAN! I was moved to read this young man’s story.

Have you ever seen Mahatma Gandhi??

If not, come and visit Thennur village near Trichy. You cannot see Mahatma Gandhi there. But you can see a ‘Young’ Gandhi there. I got a chance to go there when we went to our friend Thilaga’s marriage. Here is a man who was earning Rs 2 lakhs per month 5years ago in the US. One of his ambitions, from the time he was studying in school, is to serve his village. Hence, after earning some money for his parents, he resigned his job in the US and came to his village to start an NGO in order to support the village. He is just 36 years old now which means he resigned his job when he was 31! He is also called as ‘Ilam Gandhi’ (Young Gandhi).

So, what did he do after resigning his job?? He invested Rs 40 lakhs in Thennur to build a community health center and an informal learning center. Out of the Rs 40 lakhs which he spent, Rs 31 lakhs came out of his own pocket. He started an NGO called ‘Payir’ to help this village

Have a look at his PAYIR’s building’s below:

clip_image001

The community health center:

clip_image002

clip_image003

Informal learning center

clip_image004

Now, he has appointed 5 people who are locals and who function as his staff. They teach proper English to the schools available in their locality.

Local staffs working in Payir

clip_image005

And that is not all! He has created a small IT company within that village. This company has 4 employees as of now, who are all graduates from this village. They have a US client and are currently working on a $2500 project. This IT company is in the middle of a Coconut farm.

Have a look at their IT company below:

The IT company in the middle of a farm

clip_image006

Inside the company

clip_image007

Fan inside the IT company

clip_image008

While working in the US, he used to deposit a little money for his parents as one of his mother’s wishes was to build a house for themselves. With his savings, his parents now live in a big house at Srirangam. See the picture below:

clip_image009

But, that’s not the case with him. He lives in a small hut in that village itself.

Have a look at his room below:

clip_image010

I asked him, how he is able to live without any earnings? His reply was as follows:

“Payir trust provides me with daily food. My trustees have agreed on this. I have built a hut for myself using my past earnings. So shelter is not a problem. I have 3sets of shirts and Vesti(Dhoti) which I can use for the next 2 years. My friends will get me a few dresses once or twice in a year. What more do I need in my life??”.

Have a look at the slipper of the great man who was earning 2Lakhs a month in US:

clip_image011

When I asked, how he will manage in his old age, if he gets any disease, he coolly replied that he will go to a Govt. hospital where everything is free of cost.

My question is: How many of us will dare to act like Senthil ? Many of us have so many dreams in life like becoming a music director, to become a cricketer, to do MBA, go to the Himalayas, help the schools where we studied, to become a district collector etc etc.. But we all lose our dreams just to earn money and want to reach a position which we call it as ‘Status’. We determine our path by seeing what others are doing. We select our needs based on what others have. We select a course to study based on the job availability and its salary rather than our interest for the subject.

Every one forgets that we have only one life to achieve our dream. Many of us chase what we do not want actually. If you still have some of your dreams unfulfilled, remember that you are the reason behind it. Start now and chase your dreams!

Senthil had a dream and he started executing it now! Believe me or not. Senthil started dreaming about Payir organization during his 11th std!

Senthil - The real hero!

clip_image012

Coming to the social aspect of Senthil, how many of us will leave all that we have earned and work for the benefit of others? Have we ever dreamt of doing what Senthil has done?

While returning from Thennur, only one thing was running on my mind. If everyone of us did atleast 0.1% of what Senthil has done, our India will be much better than any other country in this world!!

If many of us continue to focus on personal growth without worrying about our nation, in future, there will be many more Senthil’s around us who would have sacrificed their personal life for the welfare of this country.

Thennur is not just another village in our India map. It is a start of a new beginning for India. Thennur is a proof of the change that youth can bring in our country.

Monday, October 12, 2009

How To Export Data in a DataGrid on an ASP . NET WebForm to Microsoft Excel

  • Start Visual Studio .NET. On the File menu, point to New, and then click Project.
  • In the Project Types pane, click Visual Basic Projects. Under Templates, click ASP.NET Web Application. Name the application ExcelExport and then click OK.
    WebForm1 appears in Design view for you.
  • In Solution Explorer, right-click WebForm1.aspx and then click Rename. Change the name of the file to Bottom.aspx.
  • On the View menu, click HTML Source to add the following DataGrid between the < form > and < / form > tags:

    <asp:datagrid id="DataGrid1" runat="server" GridLines="Vertical" CellPadding="3" BackColor="White" BorderColor="#999999" BorderWidth="1px" BorderStyle="None" Width="100%" Height="100%" Font-Size="X-Small" Font-Names="Verdana"> <SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#008A8C"></SelectedItemStyle> <AlternatingItemStyle BackColor="Gainsboro"></AlternatingItemStyle> <ItemStyle BorderWidth="2px" ForeColor="Black" BorderStyle="Solid" BorderColor="Black" BackColor="#EEEEEE"></ItemStyle> <HeaderStyle Font-Bold="True" HorizontalAlign="Center" BorderWidth="2px" ForeColor="White" BorderStyle="Solid" BorderColor="Black" BackColor="#000084"></HeaderStyle> <FooterStyle ForeColor="Black" BackColor="#CCCCCC"></FooterStyle> <PagerStyle HorizontalAlign="Center" ForeColor="Black" BackColor="#999999" Mode="NumericPages"></PagerStyle> </asp:datagrid>

  • On the View menu, click Design to return to design view.
    The DataGrid appears on the WebForm.
  • On the View menu, click Code to display the code behind the Web Form. Add the following code to the Page_Load event handler:

    Note You must change User ID <username> and password=<strong password> to the correct values before you run this code. Make sure that the user account has the correct permissions to perform this operation on the database.


    ' Create a connection and open it. Dim objConn As New System.Data.SqlClient.SqlConnection("User ID=<username>;Password=<strong password>;Initial Catalog=Northwind;Data Source=SQLServer;") objConn.Open() Dim strSQL As String Dim objDataset As New DataSet() Dim objAdapter As New System.Data.SqlClient.SqlDataAdapter() ' Get all the customers from the USA. strSQL = "Select * from customers where country='USA'" objAdapter.SelectCommand = New System.Data.SqlClient.SqlCommand(strSQL, objConn) ' Fill the dataset. objAdapter.Fill(objDataset) ' Create a new view. Dim oView As New DataView(objDataset.Tables(0)) ' Set up the data grid and bind the data. DataGrid1.DataSource = oView DataGrid1.DataBind() ' Verify if the page is to be displayed in Excel. If Request.QueryString("bExcel") = "1" Then ' Set the content type to Excel. Response.ContentType = "application/vnd.ms-excel" ' Remove the charset from the Content-Type header. Response.Charset = "" ' Turn off the view state. Me.EnableViewState = False
    Dim tw As New System.IO.StringWriter() Dim hw As New System.Web.UI.HtmlTextWriter(tw) ' Get the HTML for the control. DataGrid1.RenderControl(hw) ' Write the HTML back to the browser. Response.Write(tw.ToString()) ' End the response. Response.End()
    End If




  • NOTE: Replace SQLServer in the code with the name of your SQL Server. If you do not have access to a SQL Server that contains the Northwind sample database, modify the connection string to use the Microsoft Access 2002 sample Northwind database:

    provider=microsoft.jet.oledb.4.0; data source=C:\Program Files\Microsoft Office\Office10\Samples\Northwind.mdb

    If you select this method, modify the aforementioned code to use the OleDbClient namespace rather than the SqlClient namespace.

  • On the Project menu, click Add HTML Page. Name the page Top.htm and then click Open.
    Top.htm appears in Design view.
  • On the View menu, click HTML Source. Replace the contents of the HTML source window with the following code:

    <html> <script language="vbscript"> Sub Button1_onclick Select Case Select1.selectedIndex Case 0 ' Use Automation. Dim sHTML sHTML = window.parent.frames("bottom").document.forms(0).children("DataGrid1").outerhtml Dim oXL, oBook Set oXL = CreateObject("Excel.Application") Set oBook = oXL.Workbooks.Add oBook.HTMLProject.HTMLProjectItems("Sheet1").Text = sHTML oBook.HTMLProject.RefreshDocument oXL.Visible = true oXL.UserControl = true Case 1 ' Use MIME Type (In a New Window). window.open("bottom.aspx?bExcel=1") Case 2 ' Use MIME Type (In the Frame). window.parent.frames("bottom").navigate "bottom.aspx?bExcel=1" End Select End Sub </script> <body> Export to Excel Using: <SELECT id="Select1" size="1" name="Select1"> <OPTION value="0" selected>Automation</OPTION> <OPTION value="1">MIME Type (In a New Window)</OPTION> <OPTION value="2">MIME Type (In the Frame)</OPTION> </SELECT> <INPUT id="Button1" type="button" value="Go!" name="Button1"> </body> </html>

  • On the Project menu, click Add HTML Page. Name the page Frameset.htm and then click Open.
    Frameset.htm opens in Design view.
  • On the View menu, click HTML Source. Replace the contents of the HTML source window with the following code:

    <html> <frameset rows="10%,90%"> <frame noresize="0" scrolling="no" name="top" src="top.htm"> <frame noresize="0" scrolling="yes" name="bottom" src="bottom.aspx"> </frameset> </html>

  • In Solution Explorer, right-click Frameset.htm and then click Set As Start Page.
  • On the Build menu, click Build Solution.
  • On the Debug menu, click Start Without Debugging to run the application.
    After the frameset opens in the Web browser, the DataGrid in the bottom frame displays the data from the Northwind database.
  • In the drop-down list, click Automation, and then click Go.
    The DataGrid contents are displayed outside the browser in the Microsoft Excel application window.
  • In the drop-down list, click MIME Type (In a New Window), and then click Go.
    The DataGrid contents are displayed in Excel hosted in a new Web browser window.
    NOTE: If you receive a prompt to open or save the Excel file, click Open.
  • In the drop-down list, click MIME Type (In the Frame) and then click Go.
    The DataGrid contents are displayed in the bottom frame of the frameset in Excel hosted in the Web browser.
    NOTE: If you receive a prompt to open or save the Excel file, click Open.

    enjoy……………………..

  •