My environment is ASP.NET 2.0, C# and AJAX.
I'm having a problem with 'Button Click' logic which is trying to
display a Gridview and
then use XML/XSLT to build an Excel file. The following code does not
display the Gridview but opens the created file in Excel.If I comment
out the ExportDatasetTo Excel routine the Gridview displays correctly.
I'm assuming the problem is something to do with the Response
methods.
protected void Button1_Click(o bject sender, EventArgs e)
{
ProductLocation objProductLocat ion = new ProductLocation ();
DataSet ds;
ds = objProductLocat ion.GetProductL ocationList();
GridView1.DataS ource = ds;
GridView1.DataB ind();
string excelXsltFileNa me = "ProductLocatio nList.xsl";
string excelOutputFile Name = "ProductLocatio nList.xls";
Hashtable excelXsltArgume nts = null;
ExcelUtility.Ex portDatasetToEx cel(Server.MapP ath(excelXsltFi leName),
excelOutputFile Name,
ds,
Response,
excelXsltArgume nts
);
}
public static bool ExportDatasetTo Excel(string XSLTFileNameWit hPath,
string excelOutputFile Name, DataSet ds, System.Web.Http Response
Response, System.Collecti ons.Hashtable excelXsltArgume nts)
{
if (ds == null && ds.Tables[0].Rows.Count < 1)
return false;
Response.Clear( );
Response.Conten tType = "applicatio n/vnd.ms-excel";
Response.Append Header("Content-Disposition",
"attachment;fil ename=" + excelOutputFile Name);
XslTransform xslt = new XslTransform();
xslt.Load(XSLTF ileNameWithPath );
XsltArgumentLis t xsltArguments = new XsltArgumentLis t();
if (excelXsltArgum ents != null) // Check for parameters to be
passed to XSLT
{
foreach (System.Collect ions.Dictionary Entry de in
excelXsltArgume nts)
xsltArguments.A ddParam(de.Key. ToString(), "",
de.Value);
}
XmlDocument xml = new XmlDocument();
xml.LoadXml(ds. GetXml());
xslt.Transform( xml.CreateNavig ator(), xsltArguments,
Response.Output );
Response.Flush( );
Response.Close( );
return true;
}
Sal P. 0 1630 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Christopher M. Lauer |
last post by:
I have done my best to answer this question but can not find the
proper set of commands. I would like
to transform an xml file (in code behind) and display its output in a
specific html tag, such as a div with
a runat=server. I can somewhat do this if I create a server control
and include the control within the html
div tag but this method (borrowed from ASP.NET Website Programming by
Wrox press thanks guys) does not give me
the full...
|
by: |
last post by:
Hello,
Does anyone have an idea on how I can filter the data in the gridview
control that was returned by an sql query?
I have a gridview that works fine when I populate it with data. Now I want
to look at that data and filter it based on what is in it.
I know that this could have been done with data sets and data views in
asp.net 1.1 but how is this done now in asp.net 2.0?
|
by: Rob Roberts |
last post by:
Is there any way to prevent a ButtonField in a GridView from doing a
postback when clicked? I want to use my own onclick handler to call
window.open('SomePage.aspx') to display a page in a new browser window when
the button is clicked.
I tried doing this in the RowCommand postback event by doing this in the
event handler:
Response.Write("<script>window.open('SomePage.aspx');</script>");
|
by: steve.craver |
last post by:
I am working with a multi-field search form which, when the form is
submitted, queries a database and returns the results into a paginated
GridView object. The site is being developed with master pages.
So far, I have had success in building the search form, and passing the
values entered by the user from the form to a results page, and
displaying the entire resultset using GridView. However, when I set
the AllowPaging option on the...
|
by: Managed Code |
last post by:
Hello All,
Here is my issue and thanks in advance for any assistance.
I have a base page with a dropdownlist that fires an event with
the selected index. The content page catches the event and sets
a connection string to the database. The content page has a
simple gridview that should show records from the selected
database. Initial content page displays data from correct place.
first change of dropdownlist correctly updates content...
| |
by: John Smith |
last post by:
If anyone can help, I would very muchly appreciate it.
I have a main page that uses the .net 2.0 menu control with the multiview
controls as the menu choices. This works fine. One of the menu choices
dynamically loads a user control with a gridview (datagrid) control on it.
That works fine. The problem arises when the user clicks on a different
page of the gridview control---this is a paged gridview. When that happens,
the gridview...
|
by: cartmann |
last post by:
Hi,
I have a gridview with a template column. In the template column i have two
commandbuttons. When clicking the buttons I enter the cmd_click event - but
how do I read in which row the button was clicked??
I hope this makes sense?
/Claus
|
by: Tony Girgenti |
last post by:
Hello.
I'm trying to undetrstand ASP.NET 2.0 and javascript.
When i have a button and i click on it and i see the web broswer progress
bar at the bottom do something, does that mean that there is postback
occurring? Does that mean a round trip to the server occurred?
I keep reading javascript articles and tutorials that say "improve the
client-side experience to be more responsive and quicker", but the articles
|
by: gabe |
last post by:
How do you call a client side javascript callback method after an
update panel has posted back to the server?
I have two update panels (A + B) with a gridview in each panel.
GridView B has a Trigger to listen when GridView A posts back from a
Select button. This works fine. I can get the Postback from GridView B
and I am able to update formatting of GridView B in it's PreRender
Event.
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |