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 4574122
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T19:52:48+00:00 2026-05-21T19:52:48+00:00

I have some radiobuttons on some tabs, when I click on one it generates

  • 0

I have some radiobuttons on some tabs, when I click on one it generates an Excel-file.

<asp:RadioButton ID="rbAantallen1" runat="server" AutoPostBack="True" 
                GroupName="Soort" oncheckedchanged="rbRapport_CheckedChanged" 
                Text="Aantallen" />

The bug happens when I want to switch to the other tab. It keeps generating Excel-files. What can I do to stop running the checkedchanged event and SWITCH IN PEACE TO ANOTHER TAB?

 protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                MyDataSource.SelectCommand = @"
                    select  melder_account, 
                            aanvraag_titel, 
                            fase_datum_opgelost_oplosser, 
                            Melding_niveau_2,
                            rapporteren, 
                            fase_datum_gestart, 
                            fase_datum_opgelost, 
                            doorlooptijd, 
                            jurentkode
                    from uvw_HD_AANVRAAG_DOORLOOPTIJD_ALGEMEEN
                    where Melding_niveau_1 = 'Brandje'";
            }
        }

    protected void MenuTabs_MenuItemClick(object sender, MenuEventArgs e)
    {
        int index = Int32.Parse(e.Item.Value);
        multiTabs.ActiveViewIndex = index;
        MyDataSource.SelectCommand = BepaalDataSource(index);
    }

    public string BepaalDataSource(int index)
    {
        string select = @"
            select  melder_account, 
                    aanvraag_titel, 
                    fase_datum_opgelost_oplosser, 
                    Melding_niveau_2,
                    rapporteren, 
                    fase_datum_gestart, 
                    fase_datum_opgelost, 
                    doorlooptijd, 
                    jurentkode
            from uvw_HD_AANVRAAG_DOORLOOPTIJD_ALGEMEEN
            where Melding_niveau_1 = '";
        if (index == 0)
        {
            cbPage.Checked = false;
            return select += "Brandje'";
        }
        else
        {
            cbPage.Checked = true;
            return select += "System - Netwerk'";
        }
    }

    public DataView GetDataFromDataSource()
    {
        MyDataSource.SelectCommand = BepaalDataSource(Convert.ToInt16(cbPage.Checked));
        return MyDataSource.Select(DataSourceSelectArguments.Empty) as DataView;
    }

    protected void rbRapport_CheckedChanged(object sender, EventArgs e)
    {
        DataTable dtOriginal = (DataTable)GetDataFromDataSource().ToTable(); //Return Table consisting data
        DataTable dtTemp = new DataTable(); //Create Temporary Table

        //Creating Header Row
        dtTemp.Columns.Add("<b>Melder</b>");
        dtTemp.Columns.Add("<b>Onderwerp</b>");
        dtTemp.Columns.Add("<b>Oplosser</b>");
        dtTemp.Columns.Add("<b>Niveau 2</b>");
        dtTemp.Columns.Add("<b>Rapporteren</b>");
        dtTemp.Columns.Add("<b>Gestart op</b>");
        dtTemp.Columns.Add("<b>Opgelost op</b>");
        dtTemp.Columns.Add("<b>Doorlooptijd</b>");
        dtTemp.Columns.Add("<b>Jurentkode</b>");
        DataRow drAddItem;
        for (int i = 0; i < dtOriginal.Rows.Count; i++)
        {
            drAddItem = dtTemp.NewRow();
            drAddItem[0] = dtOriginal.Rows[i][0].ToString();//Melder
            drAddItem[1] = dtOriginal.Rows[i][1].ToString();//Onderwerp
            drAddItem[2] = dtOriginal.Rows[i][2].ToString();//Oplosser
            drAddItem[3] = dtOriginal.Rows[i][3].ToString();//Niveau 2
            drAddItem[4] = dtOriginal.Rows[i][4].ToString();//Rapporteren
            drAddItem[5] = dtOriginal.Rows[i][5].ToString();//Gestart op
            drAddItem[6] = dtOriginal.Rows[i][6].ToString();//Opgelost op
            drAddItem[7] = dtOriginal.Rows[i][7].ToString();//Doorlooptijd
            drAddItem[8] = dtOriginal.Rows[i][8].ToString();//Jurentkode
            dtTemp.Rows.Add(drAddItem);
        }

        DataGrid dg = new DataGrid(); //Temp Grid
        dg.DataSource = dtTemp;
        dg.DataBind();

        ExportToExcel("Rapport.xls", dg);
        dg = null;
        dg.Dispose();
    }

    private void ExportToExcel(string strFileName, DataGrid dg)
    {
        Response.ClearContent();
        Response.AddHeader("content-disposition", "attachment; filename=" + strFileName);
        Response.ContentType = "application/excel";
        StringWriter sw = new StringWriter();
        HtmlTextWriter htw = new HtmlTextWriter(sw);
        dg.RenderControl(htw);
        Response.Write(sw.ToString());
        Response.End();
    }

    protected void cbRapport_CheckedChanged(object sender, EventArgs e)
    {
    }
  • 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-21T19:52:49+00:00Added an answer on May 21, 2026 at 7:52 pm

    A couple things come to mind.

    In your rbRapport_CheckChanged() function you could check to make sure the radio button is visible.

    You could also check your tab control to make sure you’re on the right tab.

    EDIT
    Based on your comments, the hosting tab is invisible.

    If that’s the case, do something like this in your code

    rbRapport_CheckChanged()
    {
        if(tab1.Visible == false)
            return;
    
        <rest of code here>
    }
    

    Where tab1 is the tab that rbRapport is on. This will check, if the tab isn’t visible, you probably don’t want to create an xls, so it will just short circuit and kick out of the event. If the tab is visible, it will process the event.

    Edit
    maybe you shouldn’t be creating the xls when your radio button changes. Maybe you should have a button to click that says “Generate XLS” or something, and capture that click event. – taylonr Apr 28 at 11:42

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a script that appends some rows to a table. One of the
i have a input tag which is non editable, but some times i need
I am attempting to pull some information from my tnsnames file using regex. I
I want to have generalised email templates. Currently I have multiple email templates with
I have a login.jsp page which contains a login form. Once logged in the
I have several USB mass storage flash drives connected to a Ubuntu Linux computer
I'm in the process of porting some code from Linux to Mac OS X.
I am playing with TFS 2010, and am trying to setup a build process
I would like to get a sum from a column, with and without a
I am trying to redirect to a specific path based on HTTP_HOST or SERVER_NAME

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.