日期:2014-05-19  浏览次数:20464 次

无法获取GridView中动态添加的控件
我的目的是动态的添加一个控件,修改某行后,从该列中取出动态添加的那个控件中的值。程序如下,但实际操作中,却找不到那个控件。
============================
HTML代码(Default.aspx):
------------------------
<%@   Page   Language= "C# "   AutoEventWireup= "true "     CodeFile= "Default.aspx.cs "   Inherits= "_Default "   %>

<!DOCTYPE   html   PUBLIC   "-//W3C//DTD   XHTML   1.0   Transitional//EN "   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

<html   xmlns= "http://www.w3.org/1999/xhtml "   >
<head   runat= "server ">
        <title> </title>
</head>
<body>
        <form   id= "form1 "   runat= "server ">
        <div>
                <asp:GridView   ID= "GridView1 "   runat= "server "   AutoGenerateColumns= "False "   DataKeyNames= "CategoryID "
                        DataSourceID= "SqlDataSource1 "   OnRowDataBound= "GridView1_RowDataBound "   OnRowUpdating= "GridView1_RowUpdating "   AllowPaging= "True "   AllowSorting= "True ">
                        <Columns>
                                <asp:BoundField   DataField= "CategoryID "   HeaderText= "CategoryID "   SortExpression= "CategoryID "   />
                                <asp:BoundField   DataField= "Description "   HeaderText= "Description "   SortExpression= "Description "   />
                                <asp:BoundField   DataField= "CategoryName "   HeaderText= "CategoryName "   SortExpression= "CategoryName "   />
                                <asp:TemplateField> </asp:TemplateField>
                                <asp:CommandField   ShowEditButton= "True "   />
                        </Columns>
                </asp:GridView>
                <asp:SqlDataSource   ID= "SqlDataSource1 "   runat= "server "   ConflictDetection= "CompareAllValues "
                        ConnectionString= "Data   Source=.;Initial   Catalog=Northwind;Integrated   Security=True "
                        DeleteCommand= "DELETE   FROM   [Categories]   WHERE   [CategoryID]   =   @original_CategoryID "