In a GridView, why should I define a select method on the same page instead of a C # file?
e.g. in 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, should this method be defined in index.aspx instead of index.aspx.cs?
Error message
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: allow. after I clean the project, rebuild it. he is working now. What is the correct way to create / debug a project? How to clear the cache?
Appreciate your help.
source
share