Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 996587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:53:55+00:00 2026-05-16T06:53:55+00:00

Visual Studio 2008 .Net 3.5 C# I have a web site that has a

  • 0
Visual Studio 2008 
.Net 3.5 
C#

I have a web site that has a lot of pages with grid views. I want to be able to add an “Export to Excel” button on some of the grid views, so I started looking and found Custom Web Server Controls – see this page for an example.

This example of a custom label lets you pass in string parameters as input to the custom control:

<aspSample:WelcomeLabel ID="WelcomeLabel1" 
   runat="server" Text="Welcome" DefaultUserName="Guest">
</aspSample:WelcomeLabel>

I am not exactly sure how to get started. I am thinking that I create a custom Button control, where the id of the grid view can be passed in as a parameter – I’m just not sure how to do that, if it is even possible.

I don’t think I need to create a custom grid view control… Or, maybe I am making it too complex by looking at custom controls?

Please note: I have the code written to be able to export a grid view to an Excel file and it works fine. I need help on how to make that code more generic, so I can drop it in my ASP by a grid view and let the grid view be “exportable”.

Thanks in advance for pointing me in the right direction!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T06:53:56+00:00Added an answer on May 16, 2026 at 6:53 am

    What if we take a route where all of your buttons call the same export method that determines which gridview to use, and then sends the appropriate datasource to your Excel creator? Not sure if it would be considered dirty, but it should be pretty easy, no custom controls involved.

    Example:

    Let’s say we name all of our buttons something like this, so we can extract out their parent gridview

    <asp:LinkButton ID="PeopleGridView_exportbutton" runat="server" onclick="excel_click" />
    <asp:LinkButton ID="ShipmentsGridView_exportbutton" runat="server" onclick="excel_click" />
    <asp:LinkButton ID="ProductsGridView_exportbutton" runat="server" onclick="excel_click" />
    

    Now, we’ll make that method:

    protected void uxPrenatalSubmit_Click(object sender, EventArgs e){
      string callerControlID = ((Control)sender).ID;
      string gridveiwID = callerControlID.Replace("_exportbutton", "");
      GridView gv = (GridView) findControl(gridveiwID);
      myCustomExcelCreatorMethod(gv.DataSource); //your method thingie here
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.