473,396 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Removing buttons in Gridview

Bob Ross
119 100+
I have a GridView with some ButtonFields in it. I want to be able to export this grid into excel but I need to remove the the buttons from the buttonfields.

Is there any way to easily disable/remove the buttons from a ButtonField or ButtonFieldCell? Or I am going to have to remove the column and add it again as a BoundFeild?
Jul 23 '07 #1
7 1837
kenobewan
4,871 Expert 4TB
I would probably use a datatable instead to create the excel, normally this involves reusing the dataset. HTH.
Jul 23 '07 #2
radcaesar
759 Expert 512MB
Hey Bob, U ask this ?

for (int i = 0; i < gv.Controls.Count; i++)

{

if (gv.Controls[i].GetType() == typeof(LinkButton))

{

l.Text = (gv.Controls[i] as LinkButton).Text;

gv.Controls.Remove(gv.Controls[i]);

gv.Controls.AddAt(i, l);

}

}
Jul 23 '07 #3
radcaesar
759 Expert 512MB
Sorry Bob, I have took that vice versa...
Jul 23 '07 #4
Bob Ross
119 100+
Thats what I have done in the past. But my college has just rewritten the way it is done for another part of the site and I am trying to reuse his code as much as I can.

I have managed to get it workinf by removing the link from the cells controls and adding a label instead. Not an ideal solution but it seems to work.
Jul 23 '07 #5
Bob Ross
119 100+
Thanks for that radcaesar!
The way I managed to do it is pretty much the same as your method but I think yours slightly better so I will copy it from you.

Thanks again
Jul 23 '07 #6
radcaesar
759 Expert 512MB
Hey Bob, Mine is not an optimistic solution, Thats why i have post another message saids sorry.

But it can be used, I don't think no performance issues since we must navigate and search for controls in both the cases either in Grid or in Excel.


:)
Jul 23 '07 #7
hey Bob,are you able to remove buttonfield from the gridview before exporting it to excel,if yes plz tell me how,for the the code is working fine but i am unable to remove those buttons.plz help me.if you want i can send you the script.
i already post the script in forum " good code to expot to excel sheet but need lil help " plz check that question in forum.

thanks in advance Bob


QUOTE=Bob Ross]I have a GridView with some ButtonFields in it. I want to be able to export this grid into excel but I need to remove the the buttons from the buttonfields.

Is there any way to easily disable/remove the buttons from a ButtonField or ButtonFieldCell? Or I am going to have to remove the column and add it again as a BoundFeild?[/quote]
Sep 11 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: ABC | last post by:
I have an idea. I need to write a common gridview block which contains labels, textboxs, one girdview and some buttons. Then, I think the above block will apply on several girdview with...
3
by: NateDawg | last post by:
I'm reposting this. I'm kinda in a bind untill i get this figured out, so if anyone has some input it would sure help me out. Ok, I’ve noticed a few gridview problems floating around the forum....
4
by: | last post by:
I wanted better control over the display of the command buttons, so I created Template columns for each command. (Otherwise the GridView was putting extras spacing around the images and such.) ...
6
by: Terry | last post by:
Good morning! How do I determine which SELECT button was clicked in a GridView? The multiple SELECT buttons will be used for an application approval process. Thank you in advance for your...
2
by: dba56 | last post by:
In an ASP.Net 2.0 page using SQL Server 2K, I have a editable gridview that is bound to a SQLDataSource using stored procedures for its select and update queries. The grid works fine but is slow...
6
by: AG | last post by:
I have a gridview with a template column containing an imagebutton to delete the row. Under some condition I don't want the row to be deleted, so would like to remove the button. In the...
0
by: HockeyFan | last post by:
I have a webcontrol that was written to be used in an application that allows for updating and inserts. I want to use this same control, but setting it to read-only and not allowing inserts or...
3
by: =?Utf-8?B?SlA=?= | last post by:
<asp:GridView ID="gridResults" runat="server" AutoGenerateColumns="False" Width="98%" PageSize="25" AllowPaging="True" OnSorting="gridResults_Sorting" OnPageIndexChanging...
9
by: lilOlMe | last post by:
Hi there! I have generated a GridView that looks something like: SportName| CompanyNameX |CompanyNameY |CompanyNameZ Hockey.....| Shipping------------ |Accounting-------- |Shipping------------...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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,...
0
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...
0
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,...

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.