Click here to Skip to main content
15,896,207 members
Home / Discussions / C#
   

C#

 
GeneralRe: API Hooking Pin
Satish Pai1-Jul-09 23:10
Satish Pai1-Jul-09 23:10 
GeneralRe: API Hooking Pin
Eddy Vluggen1-Jul-09 23:32
professionalEddy Vluggen1-Jul-09 23:32 
GeneralRe: API Hooking Pin
Satish Pai1-Jul-09 23:43
Satish Pai1-Jul-09 23:43 
GeneralRe: API Hooking Pin
Eddy Vluggen2-Jul-09 0:18
professionalEddy Vluggen2-Jul-09 0:18 
GeneralRe: API Hooking Pin
Henry Minute2-Jul-09 0:08
Henry Minute2-Jul-09 0:08 
QuestionIndex was out of range. Must be non-negative and less than the size of the collection while adding combo box control to listview control Pin
puppya1-Jul-09 18:17
puppya1-Jul-09 18:17 
AnswerRe: Index was out of range. Must be non-negative and less than the size of the collection while adding combo box control to listview control Pin
Not Active1-Jul-09 18:32
mentorNot Active1-Jul-09 18:32 
GeneralRe: Index was out of range. Must be non-negative and less than the size of the collection while adding combo box control to listview control Pin
puppya1-Jul-09 18:37
puppya1-Jul-09 18:37 
AnswerRe: Index was out of range. Must be non-negative and less than the size of the collection while adding combo box control to listview control Pin
Vikram A Punathambekar1-Jul-09 19:53
Vikram A Punathambekar1-Jul-09 19:53 
QuestionDirectX + Secondary monitor Pin
thomaxz.tc1-Jul-09 10:47
thomaxz.tc1-Jul-09 10:47 
AnswerRe: DirectX + Secondary monitor Pin
I Believe In GOD1-Jul-09 10:57
I Believe In GOD1-Jul-09 10:57 
GeneralRe: DirectX + Secondary monitor Pin
thomaxz.tc1-Jul-09 13:30
thomaxz.tc1-Jul-09 13:30 
Questionabout the usinhg Visual Studio 2010 beta 1 Pin
Seraph_summer1-Jul-09 10:23
Seraph_summer1-Jul-09 10:23 
AnswerRe: about the usinhg Visual Studio 2010 beta 1 Pin
Pete O'Hanlon1-Jul-09 10:30
mvePete O'Hanlon1-Jul-09 10:30 
GeneralRe: about the usinhg Visual Studio 2010 beta 1 Pin
Seraph_summer1-Jul-09 10:35
Seraph_summer1-Jul-09 10:35 
GeneralRe: about the usinhg Visual Studio 2010 beta 1 Pin
Pete O'Hanlon1-Jul-09 11:15
mvePete O'Hanlon1-Jul-09 11:15 
GeneralRe: about the usinhg Visual Studio 2010 beta 1 Pin
Mycroft Holmes1-Jul-09 21:33
professionalMycroft Holmes1-Jul-09 21:33 
GeneralRe: about the usinhg Visual Studio 2010 beta 1 Pin
Pete O'Hanlon1-Jul-09 22:07
mvePete O'Hanlon1-Jul-09 22:07 
GeneralRe: about the usinhg Visual Studio 2010 beta 1 Pin
Mycroft Holmes1-Jul-09 22:45
professionalMycroft Holmes1-Jul-09 22:45 
AnswerRe: about the usinhg Visual Studio 2010 beta 1 Pin
Vikram A Punathambekar1-Jul-09 19:55
Vikram A Punathambekar1-Jul-09 19:55 
AnswerRe: about abusing Visual Studio 2010 beta 1 Pin
OriginalGriff1-Jul-09 23:28
mveOriginalGriff1-Jul-09 23:28 
QuestionDatalist to pdf [modified] Pin
ferronrsmith1-Jul-09 10:12
ferronrsmith1-Jul-09 10:12 
AnswerRe: Datalist to pdf Pin
I Believe In GOD1-Jul-09 11:00
I Believe In GOD1-Jul-09 11:00 
PDFSharp


or you can try this code


//SQL Connection Settings -----------
public string strConn = ConfigurationManager.ConnectionStrings["BLAH-Here"].ConnectionString;
//-----------------------------------

protected void Page_Load(object sender, EventArgs e)
{
//Grab the same data as the datagrid [report view] on the reporting page
//Then set the "ContentType" to "application/vnd.ms-excel" which will generate the .XSL file

//---Retrieve the Report from SQL, drop into DataSet, then Bind() it to a DataGrid
SqlConnection conn = new SqlConnection(strConn);
conn.Open();
SqlDataAdapter cmd1 = new SqlDataAdapter("EXEC [dbo].[spStatReport] @CompanyID=" + Session["CompanyID"] + ", @StatReportID=" + Request.QueryString["ReportID"].ToString() + ", @StartDate='" + Request.QueryString["StartDate"].Replace("-", "/").ToString() + "', @EndDate='" + Request.QueryString["EndDate"].Replace("-", "/").ToString() + "';", conn);
cmd1.SelectCommand.CommandType = CommandType.Text;
DataSet dsReports = new DataSet("tblReporting");
cmd1.Fill(dsReports);
conn.Close();

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();
}


I know nothing , I know nothing ...

GeneralRe: Datalist to pdf Pin
ferronrsmith1-Jul-09 12:26
ferronrsmith1-Jul-09 12:26 
QuestionDocument Viewer control Pin
CoLeichty1-Jul-09 8:26
CoLeichty1-Jul-09 8:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.