0

我有一个有效的网格视图,数据绑定列提取正确的信息,但是当我尝试添加模板字段时,我在浏览器中收到以下错误:

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?)

我这样声明的网格视图:

     <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>

我这样声明的模板字段:

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

我想要达到的效果是将按钮与网格完美对齐,到目前为止,我的策略是创建这个模板化字段并在标题中插入,让所有其他单元格为空,该列没有其他目的,只是容纳按钮,使其与网格对齐。

问题是这是我第一次使用网格视图和模板化字段,即使是这个简单的测试来查看我是否可以创建一个空列也不起作用。

4

1 回答 1

1

您必须在您的 cs 文件中定义方法 gwOrderInvQuote_SelectedIndexChanged:

 protected void gwOrderInvQuote_SelectedIndexChanged(object sender, EventArgs e)
 {
 // insert logic here
 }
于 2012-11-22T11:09:00.897 回答