473,769 Members | 3,305 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Exporting data from (All columns in data grid EXCEPT THE 1st) to E

Hi,

I am exporting data from an EDITABLE DATA GRID EXCEL. But the 1st column
in data grid is Edit Column. I want to display all columns in Excel except
for the Edit column.

The following code which I am using allows exporting only from text data
from data grid & not from Edit columns which are link buttons. How to leave
this column while displaying data from data grid in Excel?

Code:
public void PerformExcelVie w()
{
Response.Clear( );
Response.Buffer = true;
Response.Conten tType = "applicatio n/vnd.ms-excel";
Response.Charse t = "";
this.EnableView State = false;

System.IO.Strin gWriter SW = new System.IO.Strin gWriter();
System.Web.UI.H tmlTextWriter HTW = new System.Web.UI.H tmlTextWriter(S W);
DataGrid1.Rende rControl(HTW);
Response.Write( SW.ToString());
Response.End();
}

// From button click I am calling this function

private void btnExcel_Click( object sender, System.EventArg s e)
{
PerformExcelVie w();
}

Also, I tried to REMOVE theEDIT COLUMN on button click
.....DataGrid1. Columns.Remove( DataGrid1.Colum ns[0]);
& then calling the function PerfromExcelVie w() but I got the error:
"Index was out of range. Must be non-negative and less than the size of the
collection. Parameter name: index ".

How to get over this problem?
Any help will be appreciated .

Thanks
--
pmud
Nov 19 '05 #1
2 2310
Check this out,
http://weblogs.asp.net/dneimke/archi.../27/63348.aspx

There are some comments by some people who have your problem, and a solution

--Michael

"pmud" <pm**@discussio ns.microsoft.co m> wrote in message news:30******** *************** ***********@mic rosoft.com...
Hi,

I am exporting data from an EDITABLE DATA GRID EXCEL. But the 1st column
in data grid is Edit Column. I want to display all columns in Excel except
for the Edit column.

The following code which I am using allows exporting only from text data
from data grid & not from Edit columns which are link buttons. How to leave
this column while displaying data from data grid in Excel?

Code:
public void PerformExcelVie w()
{
Response.Clear( );
Response.Buffer = true;
Response.Conten tType = "applicatio n/vnd.ms-excel";
Response.Charse t = "";
this.EnableView State = false;

System.IO.Strin gWriter SW = new System.IO.Strin gWriter();
System.Web.UI.H tmlTextWriter HTW = new System.Web.UI.H tmlTextWriter(S W);
DataGrid1.Rende rControl(HTW);
Response.Write( SW.ToString());
Response.End();
}

// From button click I am calling this function

private void btnExcel_Click( object sender, System.EventArg s e)
{
PerformExcelVie w();
}

Also, I tried to REMOVE theEDIT COLUMN on button click
....DataGrid1.C olumns.Remove(D ataGrid1.Column s[0]);
& then calling the function PerfromExcelVie w() but I got the error:
"Index was out of range. Must be non-negative and less than the size of the
collection. Parameter name: index ".

How to get over this problem?
Any help will be appreciated .

Thanks
--
pmud

Nov 19 '05 #2
Thanks Raterus. This was helpful.

"Raterus" wrote:
Check this out,
http://weblogs.asp.net/dneimke/archi.../27/63348.aspx

There are some comments by some people who have your problem, and a solution

--Michael

"pmud" <pm**@discussio ns.microsoft.co m> wrote in message news:30******** *************** ***********@mic rosoft.com...
Hi,

I am exporting data from an EDITABLE DATA GRID EXCEL. But the 1st column
in data grid is Edit Column. I want to display all columns in Excel except
for the Edit column.

The following code which I am using allows exporting only from text data
from data grid & not from Edit columns which are link buttons. How to leave
this column while displaying data from data grid in Excel?

Code:
public void PerformExcelVie w()
{
Response.Clear( );
Response.Buffer = true;
Response.Conten tType = "applicatio n/vnd.ms-excel";
Response.Charse t = "";
this.EnableView State = false;

System.IO.Strin gWriter SW = new System.IO.Strin gWriter();
System.Web.UI.H tmlTextWriter HTW = new System.Web.UI.H tmlTextWriter(S W);
DataGrid1.Rende rControl(HTW);
Response.Write( SW.ToString());
Response.End();
}

// From button click I am calling this function

private void btnExcel_Click( object sender, System.EventArg s e)
{
PerformExcelVie w();
}

Also, I tried to REMOVE theEDIT COLUMN on button click
....DataGrid1.C olumns.Remove(D ataGrid1.Column s[0]);
& then calling the function PerfromExcelVie w() but I got the error:
"Index was out of range. Must be non-negative and less than the size of the
collection. Parameter name: index ".

How to get over this problem?
Any help will be appreciated .

Thanks
--
pmud

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
3841
by: Hutty | last post by:
I've looked around and have yet to find anything that would answer my question regarding formating a column in a datagrid. My grid looks like this as far as data" AMHQCON|51300.01|-3147 The first two columns are pretty much text column, but subsequent columns 1-12 are numerical. I'm trying to get the thousand separator to work. Any ideas?
3
2219
by: pmud | last post by:
Hi, I have a web page (asp.net, code:c#). I havean html table with text boxes. Based on the user input , records are displayed in the data grid below it. Now the datagrid has a large no. of columns. & depending on what the user enters, the data grid can grow very large. So to avoid scrolling the whole page, I just want the data grid to be scrollable. For this I used the <div> tags around the data grid, <div...
0
1737
by: Tim_k | last post by:
Does anyone have an example of how to export a datagrid to an Excel pivot table? The code below exports the grid contents to Excel using the Response object. I'd like to expand it to show the data in a pivot table. Avoiding a 3rd party control is preferable. Thanks, Tim Response.ContentType = "application/vnd.ms-excel" Response.Charset = ""
2
1063
by: JIM.H. | last post by:
Hello, I have a DataGrid1 object in my asp.net web application, it has 5 columns and it shows data retrieved from a table. That part is ok, I see all the data. I am quite new and I succeeded that much. Now I want to take 1st and 3rd column from the grind and append it into another table in my database. How should I do this? Thanks, Jim.
1
1072
by: shl | last post by:
My app is for data entry over the web. The user enters data into a datagrid on the 1st pg, which I put into a datatable ( this datatable has 10 columns, and could be up to about 100 rows). When the user is finished with this data entry, he goes to the 2nd pg, where another data grid is displayed, and some of the data (about 5 of the columns from the 1st pg)is to be displayed in the datagrid in read only mode, and the user can enter more...
6
2564
by: Opa | last post by:
Hi, I have a DataGrid, whose sourceI am exporting to Excel. This works fine except for the Column ordering. My datasource is not a datatable, with a typical SELECT statement where I can select the column orders. Instead the datasource is a class which implements IList, containing a collection of my data. My problem again is that I don't know how to control the order of the columns that are exported.
4
2518
by: Tom | last post by:
I have a gridview on all of my web pages in my web app and they all export to excel. I have one page where the gridview is binding to a datatable that i created and only the first column is exporting to excel. How can I get the entire grid to export to excel?
2
1662
by: heba84 | last post by:
i have aproblem when exporting grid view to excel all columns display correct except the arabic ones it SOMETIMES look like garbage I try: Response.Charset = "utf-8"; but it doesnt work and tryed:
6
2945
by: insirawali | last post by:
Hi all, I have this problem, i need to know is there a way i cn use the data adapter's update method in this scenario. i have 3 tables as below create table table1{ id1 int identity(1,1) Constraint pk_table1 Primary Key,
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10216
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10049
jinu1996
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...
0
8873
agi2029
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...
0
6675
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();...
0
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3965
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
2
3565
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.