0

I have a Grid View which works, the data bound columns extract the proper information but when I try to add a Template Field I get the following error in the browser:

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

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

The Grid View I declared it as such:

     <asp:View ID="Foo" runat="server">
                <asp:GridView ID="Foo" runat="server" DataKeyNames="id"
                    DataSourceID="odsFoo" Width="631px" OnRowDataBound="gwFoo_RowDataBound"
                    CssClass="customerDataTable" AllowSorting="True" 
                    onselectedindexchanged="gwOrderInvQuote_SelectedIndexChanged">
                    <Columns>

The Template Field I declared it as such:

 <asp:TemplateField AccessibleHeaderText="fhfj">
            <HeaderTemplate> This is a Test </HeaderTemplate>
            <ItemTemplate> </ItemTemplate>
 </asp:TemplateField>

The effect I'm trying to achieve is to line up a button perfectly with the grid, my strategy thus far is to create this templated field and insert the in the header leaving all the other cells empty, the column has no other purpose but to house the button so that it is aligned with the grid.

The problem being that this is the first time I'm working with a grid view and the templated field and even this simple test to see if I can create a empty column doesn't work.

George Bora
  • 1,618
  • 6
  • 26
  • 45

1 Answers1

1

You have to define method gwOrderInvQuote_SelectedIndexChanged in your cs file:

 protected void gwOrderInvQuote_SelectedIndexChanged(object sender, EventArgs e)
 {
 // insert logic here
 }
Boriss Pavlovs
  • 1,441
  • 12
  • 8
  • I'm sorry but shouldn't generic methods like these, changing a index be created by default, I don't have any particular logic in mind for a index being changed beside "standard stuff that happens" so I don't have any idea on what to implement. – George Bora Nov 22 '12 at 11:17
  • 1
    if you haven't got any logic simply stay method body empty or remove attribute onselectedindexchanged="gwOrderInvQuote_SelectedIndexChanged" from gridview declaration. – Boriss Pavlovs Nov 22 '12 at 11:24