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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:48:10+00:00 2026-06-03T17:48:10+00:00

In the GridView, why I have to define select method in the same page

  • 0

In the GridView, why I have to define select method in the same page instead of C# file ?

for example, in the index.aspx, I have

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="index.aspx.cs" Inherits="GridViewApp.index" %>     
<asp:GridView ID="GridView1" runat="server" 
          onselectedindexchanged="GridView1_SelectedIndexChanged" 
        DataSourceID="SqlDataSource2" AllowPaging="True" AllowSorting="True">
            <Columns>
                <asp:CommandField ShowSelectButton="True"  />
            </Columns>
        </asp:GridView>

GridView1_SelectedIndexChanged, this method have to be defined in the index.aspx instead of index.aspx.cs ?

The error message is

Compiler Error Message: CS1061: 'ASP.index_aspx' does not contain a definition for 'GridView1_SelectedIndexChanged' and no extension method 'GridView1_SelectedIndexChanged' accepting a first argument of type 'ASP.index_aspx' could be found (are you missing a using directive or an assembly reference?)

UPDATED:
resolve. after I clean the project, rebuild it. it works now. what is the correct way to build / debug a project ? how to clean cache ?

Appreciate your help.

  • 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-03T17:48:12+00:00Added an answer on June 3, 2026 at 5:48 pm

    The method GridView1_SelectedIndexChanged needs to be defined on the page that contains the GridView1 and make sure that you declare it at least as protected

    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
       //do magic
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a gridview defined in aspx page as defined below: have defined event
I have a GridView which I am populating by calling a method to return
I have a gridview were I define some columns, like this... <GridViewColumn.CellTemplate> <DataTemplate> <TextBlock
I have a gridview which is defined as follows: <asp:GridView ID=ComponentGridView runat=server AutoGenerateColumns=true OnPageIndexChanging=ComponentGridView_PageIndexChanging
I have a GridView control on my page that I have defined a number
I have a HyperLinkField defined as follows: <asp:GridView ID=gvNotifications runat=Server AutoGenerateColumns=false EnableViewState=true CssClass=tableWhole AlternatingRowStyle-CssClass=tableAlt>
Well i have a gridview where i have defined the columns on my own
I have a gridview data and this gridview have subgrid too. in the first
I have a gridview that shows an image as part of one of its
I have a GridView what I fill through a LINQ expression. Something like this:

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.