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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:50:37+00:00 2026-06-02T00:50:37+00:00

The filters work for myTicketsSubmitButton but not work allTicketsSubmitButton. The code is the same

  • 0

The filters work for myTicketsSubmitButton but not work allTicketsSubmitButton. The code is the same but I don’t understand why it works for one method and not another.

I am using WinForms and C# with Visual Studio 2010

    private void myTicketsSubmitButton_Click(object sender, EventArgs e)
    {
        String sqlQuery = "SELECT u.CallerName, t.* FROM users u INNER JOIN tickets t ON u.id = t.user WHERE u.CallerName = '" + Environment.UserName.ToLower() + "'";
        GetData(sqlQuery);

        if (myTicketsAllRadioButton.Checked)
        {
            //GetData(sqlQuery);
            ticketsBindingSource.Filter = "ProblemStatus LIKE '%'";
        }

        if (myTicketsClosedRadioButton.Checked)
        {
            //GetData(sqlQuery);
            ticketsBindingSource.Filter = "ProblemStatus = 'Closed'";
        }

        if (myTicketsOpenRadioButton.Checked)
        {
            //GetData(sqlQuery);
            ticketsBindingSource.Filter = "ProblemStatus = 'Open'";                
        }
    }

    private void allTicketsSubmitButton_Click(object sender, EventArgs e)
    {
        String sqlQuery = "SELECT u.CallerName, t.* FROM users u INNER JOIN tickets t ON u.id = t.user";
        GetData(sqlQuery);

        if (myTicketsAllRadioButton.Checked)
        {
            //GetData(sqlQuery);
            ticketsBindingSource.Filter = "ProblemStatus LIKE '%'";
        }

        if (myTicketsClosedRadioButton.Checked)
        {
            //GetData(sqlQuery);
            ticketsBindingSource.Filter = "ProblemStatus = 'Closed'";
        }

        if (myTicketsOpenRadioButton.Checked)
        {
            //GetData(sqlQuery);
            ticketsBindingSource.Filter = "ProblemStatus = 'Open'";               
        }
    }

    private void GetData(string selectCommand) 
    {
        OleDbDataAdapter dataAdapter = new OleDbDataAdapter();
        BindingSource bindingSource1 = new BindingSource();
        try 
        {
            // Specify a connection string. Replace the given value with a  
            // valid connection string for a Northwind SQL Server sample 
            // database accessible to your system.
            String connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\testdb.accdb";

            // Create a new data adapter based on the specified query. 
            dataAdapter = new OleDbDataAdapter(selectCommand, connectionString);

            // Create a command builder to generate SQL update, insert, and 
            // delete commands based on selectCommand. These are used to 
            // update the database. 
            OleDbCommandBuilder commandBuilder = new OleDbCommandBuilder(dataAdapter);

            // Populate a new data table and bind it to the BindingSource. 
            DataTable table = new DataTable(); 
            table.Locale = System.Globalization.CultureInfo.InvariantCulture; 
            dataAdapter.Fill(table); 
            bindingSource1.DataSource = table;
            ticketsBindingSource = bindingSource1;

            // Resize the DataGridView columns to fit the newly loaded content. 
            //ticketsDataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);                

            ticketsDataGridView.DataSource = bindingSource1;
        }
        catch(OleDbException)
        {
            MessageBox.Show("To run this example, replace the value of the connectionString variable with a connection string that is valid for your system.");
        }
    }

I have 6 Radio buttons.

3 of them are for myTickets
–Open
–Closed
–All

3 of them are for allTickets
–Open
–Closed
–All

When I click the radio buttons for myTickets group, everything works

I made a small change to the code but the allTicketsSubmitButton doesn’t display all the tickets for Open or All tickets.

The database is relatively small so I can quickly test things as I go.

I have 5 entries
2 Open
2 Closed
1 Work In Progress

2 Entries are assigned to another user (so 3 of them are myTickets).

I noticed something weird

The results display correctly ONLY if I set the radio button for myTickets and allTickets to the same thing

(both open will display the open tickets)
if one is open and the other is closed, then nothing happens

  • 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-06-02T00:50:38+00:00Added an answer on June 2, 2026 at 12:50 am

    If you have 6 radio buttons, 3 for the myTickets and 3 for allTickets then why do you have your myTickets being checked under your allTickets button click event?

    I think you need to change your code from:

    private void allTicketsSubmitButton_Click(object sender, EventArgs e)
        {
            String sqlQuery = "SELECT u.CallerName, t.* FROM users u INNER JOIN tickets t ON u.id = t.user";
    
            if (myTicketsAllRadioButton.Checked)
            {
                GetData(sqlQuery);
                ticketsBindingSource.Filter = "ProblemStatus LIKE '%'";
            }
    
            if (myTicketsClosedRadioButton.Checked)
            {
                GetData(sqlQuery);
                ticketsBindingSource.Filter = "ProblemStatus = 'Closed'";
            }
    
            if (myTicketsOpenRadioButton.Checked)
            {
                GetData(sqlQuery);
                ticketsBindingSource.Filter = "ProblemStatus = 'Open'";               
            }
        }
    

    TO:

    private void allTicketsSubmitButton_Click(object sender, EventArgs e)
        {
            String sqlQuery = "SELECT u.CallerName, t.* FROM users u INNER JOIN tickets t ON u.id = t.user";
            GetData(sqlQuery); // move this here, you only need this in one place
    
            if (allTicketsAllRadioButton.Checked)
            {
                ticketsBindingSource.Filter = "ProblemStatus LIKE '%'";
            }
    
            if (allTicketsClosedRadioButton.Checked)
            {
                ticketsBindingSource.Filter = "ProblemStatus = 'Closed'";
            }
    
            if (allTicketsOpenRadioButton.Checked)
            {
                ticketsBindingSource.Filter = "ProblemStatus = 'Open'";               
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm going to work on a Customer Profiling project (similar but not same to
Hey all i've been using some filters. Not all of them seem to work
I've created a Web Api filter (using System.Web.Http.Filters.ActionFilterAttribute ) but I am unable to
Does anyone have any idea why this code seems not to work? What am
Could you please help me that this code doesn't work in IE? But this
I've read through the custom tags and filters documentation , but I'm not seeing
CI Filters are now available in iOS 5, and I'm trying to apply one
I have multiple filters in my application, with one at the root. <filter> <filter-name>root</filter-name>
For some reason I can't get my SVG filters to work in Firefox. They
I am having trouble getting my filters/validators to work correctly on my form, so

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.