What is the difference between Server.Transfer and
Response.Redirect? Why would you choose one over the other?

Answer Posted / d

using System.Data.OleDb;

string strFilePath = @"D:\Development\Test.xlsx";
try {
string strConnectionString = string.Empty;
//strConnectionString =
@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
strFilePath + @";Extended Properties=""Excel
8.0;HDR=YES;IMEX=1""";
strConnectionString =
@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" +
strFilePath + @";Extended Properties=""Excel 12.0
Xml;HDR=YES;IMEX=1""";
OleDbConnection cnCSV = new OleDbConnection
(strConnectionString);
cnCSV.Open();
OleDbCommand cmdSelect = new OleDbCommand
(@"SELECT * FROM [Sheet1$]", cnCSV);
OleDbDataAdapter daCSV = new OleDbDataAdapter();
daCSV.SelectCommand = cmdSelect;
DataTable dtCSV = new DataTable();
daCSV.Fill(dtCSV);
cnCSV.Close();
daCSV = null;

Response.Write(dtCSV.Rows.Count);
gvTest.DataSource = dtCSV;
gvTest.DataBind();


} catch (Exception ex) {
} finally {
}


<asp:GridView ID="gvTest" runat="server"
AutoGenerateColumns="false">
<Columns>
<asp:BoundField HeaderText="GDCID" DataField="GDCID" />
<asp:BoundField HeaderText="EmpID" DataField="EmpID" />
</Columns>
</asp:GridView>

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can action method static?

523


Is asp.net free?

544


How can we identify that the Page is Post Back?

550


When should I use server transfer and response redirect?

503


What is simple data binding?

506






What is the difference between page-level caching and fragment caching?

520


Explain About WebService

644


I’m having some trouble with cas. How can I diagnose my problem?

575


What would be salary for 8+ years of experience in ASP.NET in different metro city in india?

1978


What is the difference between localization and globalization?

550


Define dll hell?

618


What is a user developed application?

513


Elaborate differentiation between ViewState and SessionState?

603


What is protected configuration?

593


Difference between .NET and previous version?

2090