Tuesday, April 23, 2013

Export to Excel from GridView in C#

This sample code will help you export data from GridView to Excel and formatting Excel file in C# . Follow the below process:
    protected void ExportToExcel_Click(object sender, EventArgs e)
    {
        BindgvPDRecovery(); // Bind GridView1
        Response.ClearContent();
        Response.Buffer = true;
        Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "Report.xls"));
        Response.ContentType = "application/vnd.xls";
        StringWriter sw = new StringWriter();
        HtmlTextWriter htw = new HtmlTextWriter(sw);
        GridView1.AllowPaging = false; GridView1.DataBind();
        GridView1.HeaderRow.Style.Add("background-color", "#000000");
        GridView1.RenderControl(htw);
        Response.Write(sw.ToString());
        Response.End();
}

If have any query feel free ask me please.
Hope this helps !!

Tuesday, April 9, 2013

ASP.NET Interview Questions and Answers

=>
What is ASP.NET?

ASP.NET is a server side scripting technology that enables scripts (embedded in web pages) to be executed by an Internet server.
ASP.NET provides increased performance by running compiled code.
=>
What is Difference between Namespace and Assembly?

Namespace is a logical design-time naming convenience, whereas an assembly establishes the name scope for types at run time.

=>
What is the difference between early binding and late binding?

Calling a non-virtual method, decided at a compile time is known as early binding. Calling a virtual method (Pure Polymorphism), decided at a runtime is known as late binding.

=>
What is the difference between Server.Transfer and response.Redirect?

The Server.Transfer () method stops the current page from executing, and runs the content on the specified page, when the execution is complete the control is passed back to the calling page.
While the Response.Redirect () method transfers the control on the specified page and the control is never passed back to calling page after execution.


Wednesday, April 3, 2013

HR Interview Questions and Answers

# Tell me about yourself.

I'm XY from Dhaka.First of all I would like to thank you for given wonderful opportunity to introduce myself.Coming to my education background...I have completed MSc. in Computer science & Engineering from Islamic University Bangladesh. BSc in Computer science & engineering from Islamic University Bangladesh. Higher Secondary Certificate completed from Kushtia govt. college my schooling in Kushtia Zilla school. Coming to my area of interest.....My interest is software development and web application development. I always want to give optimal functionality to my Project that should be different from others. I have 6 years experience on software development. I am Microsoft certified technology specialist. My hobbies are playing cricket and listening songs. My strengths are I'm a Goal Oriented Person, I'm also team player (also I can work alone) , Fast Learner, and Keen to Details. I just believe in hard working and punctuality. Thanks to be a part of best listener.

#why should I hire you ?

Sir, you should hire me because, I will fulfill the all requirements required for this job, and I think this is the correct platform where I can enhance my skills in organization and explore my skills in the organization. I know your company is a wonderful opportunity for me to improve and achieve my goals.

#What are your strengths and weaknesses ?

My strengths are, I am a positive attitude person, quick learner and I am a hard worker as well as smart worker. I will be very flexible for given environment.

I am straightforward person & very emotional. I never comfortable feel until finish my work.

#Why do you want to work at our company ?

Everybody wants to work in reputed company like your and this organization is the good platform where I can improve my skills and learn new thing also.

#What are your goals?

My short term goal is to get a job in reputed company where I can utilize my skills and improve my career path. My long term goal is to be in respectable position in that organization.

#How long would you expect to work for us if hired ?

Sir, if you will give me a chance to work with this organization. I will work for the organization as long company will require my services. I would love to the part of organization as long as my skills and my knowledge will benefit both of us.

#Do you have any questions for me ?

I would like to know about the career growth I can expect being with this company. I am quite an ambitious person and this information will be helpful.

#Ideal Company

An ideal company is one where I can utilize my skills and abilities and can gain more knowledge. An ideal job is one which gives self satisfaction to me.
I can adapt to any new environment.

#Why did you resign from your previous job ?

I am very thankful to my previous organization because I have learnt lot things from there. According to me changes are necessary for everyone to enhance my skills, knowledge personal growth and financial growth. Your organization is the good platform where I can learn more.
Moreover new environment is always motivate us and gives the energy to do something better in the life. Why have you had so many jobs

#Why have you had many company?

Though I have changed lot of jobs but due to this I have learn different set of skills. And these skills help me a lot in dealing with different kinds of children and people. It show negativity on my part but my skills and learning ability have increased.

#How could you have improved your career progress?

To improve carrier, self confidence, +ve attitude, smart working, hardworking, dedication, punctuation, honesty and wish to learn new thing are required. And I have those points so because of that I could have improved myself.

Tuesday, April 2, 2013

[Solved]Flash file upload, windows authentication problem IIS7

[The problem When i try to upload file then asks me for windows authentication by windows dialogue box.
Its working fine my development machine but on live system it comes up with windows authentication.]

I have solved this problem to configure iis. Please see bellow image.


Right Click on "Windows Authintication" then select --> "Advance Settings"-->"Extended Protection"-->Select "Required" from dropdown-->Click "OK"
Happy Programming :)

Monday, April 1, 2013

[Solved]Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack

In this case you have to do this:
In place of Response.End() you have to use HttpContext.Current.ApplicationInstance.CompleteRequest()

and in place of Response.Redirect, use the Response.Redirect ("Error.aspx", false);
and in place of Server.Transfer, use the Server.Execute method