网格视图中 ASP.NET 模板字段错误



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

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>
我试图实现的效果是将按钮与网格完美对齐,

到目前为止,我的策略是创建此模板字段并在标题中插入,将所有其他单元格留空,该列没有其他目的,只能容纳按钮以便它与网格对齐。

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

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

 protected void gwOrderInvQuote_SelectedIndexChanged(object sender, EventArgs e)
 {
 // insert logic here
 }

相关内容

  • 没有找到相关文章

最新更新