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.
The method
GridView1_SelectedIndexChangedneeds to be defined on the page that contains theGridView1and make sure that you declare it at least asprotected