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

  • SEARCH
  • Home
  • 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 8711045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:46:48+00:00 2026-06-13T04:46:48+00:00

I am building a simple C# web app which will act like an online

  • 0

I am building a simple C# web app which will act like an online database for resources.

In my table, I have a category and author column.

When I click a category value in the table, the table will refresh showing only the categories that was selected.

To do this I used the following code:

GridViewRow clickedRow = ((LinkButton)sender).NamingContainer as GridViewRow;

Label category = (Label)clickedRow.FindControl("lbl_category");

String selectedCategory = category.Text.ToString();

string query = 
("SELECT * FROM main WHERE category='" + selectedCategory + "' ORDER BY ID ASC");

This works fine for the first time I click a category/author. But after the table has refreshed, and select another category or author then the table shows the wrong record.

How can I solve this?

You can view the page here: Try clicking at category 'Health' and then 'Puvent, Kevin'. The outcome is different to the one that was expected. I think

The question will probably make more sense once you see the page 🙂

EDIT – This is the gridview binding code:

<asp:TemplateField HeaderText="Category" ItemStyle-Width="15%">
<ItemTemplate>
<asp:Label ID="lbl_category" Text='<%# Bind("category")%>' runat="server" style="display:none;"></asp:Label>
<asp:LinkButton ID="lbl_linkCategory" Text='<%# Bind("category")%>' runat="server" OnClick="linkCategory" CommandArgument='<%# Bind("category")%>' />
</ItemTemplate>
</asp:TemplateField>
  • 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-13T04:46:49+00:00Added an answer on June 13, 2026 at 4:46 am

    Using if (!IsPostBack) in Page_Load seemed to have solved the problem 🙂

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

Sidebar

Related Questions

I'm building a web app which will have an api and an authorization service
I'm currently building a web app that will take some info from a database
Building a simple asp.net web app just to test things out (will obviously refactor
I'm looking at building a simple web app that will expose an API that
For a YouTube web-app I'm building in PHP, I have the simple video player,
I'm building a web app to design and animate simple 3d scenes using the
I'm building a simple availability calendar with PHP and MySQL. I have a table
I'm building a simple game in an ASP.NET/VB.NET web app. The game has a
I have a web application that relies on a MySQL database, for which I
I'm building a Zend-based Web app that will permit third-party extensions. Essentially, this application's

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.