我有一个可用的网格视图,数据绑定列提取正确的信息但是当我尝试添加模板字段时,我在浏览器中收到以下错误:
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>
我想要实现的效果是与网格完美地排列一个按钮,到目前为止,我的策略是创建这个模板化的字段并插入标题中,使所有其他单元格为空,列没有其他目的,但要容纳按钮,使其与网格对齐。
问题是这是我第一次使用网格视图和模板化字段,甚至这个简单的测试,看看我是否可以创建一个空列不起作用。
答案 0 :(得分:1)
您必须在cs文件中定义方法gwOrderInvQuote_SelectedIndexChanged:
protected void gwOrderInvQuote_SelectedIndexChanged(object sender, EventArgs e)
{
// insert logic here
}