2012-11-22 30 views
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> 

我試圖達到的效果是排列一個完美的按鈕與網格,我的策略到目前爲止是創建此模板字段並插入標題中留下所有其他單元格爲空,該列沒有其他目的,但放置按鈕,使其與網格對齊。

問題是,這是我第一次使用網格視圖和模板化字段,甚至是這個簡單的測試,看看我是否可以創建一個空列是行不通的。

回答

1

您的CS文件中定義的方法gwOrderInvQuote_SelectedIndexChanged:

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

我很抱歉,但不應被默認創建的通用方法,如這些,改變一個指數,我沒有任何具體的邏輯考慮到在「發生的標準事件」旁邊改變索引,所以我不知道要實施什麼。 –

+1

如果您沒有任何邏輯,只需將方法體留空或從gridview聲明中刪除屬性onselectedindexchanged =「gwOrderInvQuote_SelectedIndexChanged」。 –