首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

火大啊动态加载的用户控件中的gridview咋不能执行删除事件?该怎么处理

2012-01-19 
火大啊.动态加载的用户控件中的gridview咋不能执行删除事件???????%@ControlLanguage C# AutoEventWir

火大啊.动态加载的用户控件中的gridview咋不能执行删除事件???????
<%@   Control   Language= "C# "   AutoEventWireup= "true "   CodeFile= "Mm.ascx.cs "   Inherits= "UC_Admin_Mm "   %>
<table   style= "word-break:break-all "   width= "600 "   cellspacing= "0 "   align= "center "   cellpadding= "0 "   border= "0 ">
    <tr> <td     colspan= "3 "> <img   src= "style/images/photoup.gif "   width= "100% "   height= "10 "   > </td>
    </tr>
    <tr   height= "30 ">
        <td   width= "1 "   class= "backs "> </td>
        <td   width= "498 "class= "backq ">
<p   style= "line-height:   140%;   margin-left:   12;   margin-top:   0;   margin-bottom:   5 "> <img   src= "style/images/tb_title.gif "   align=absmiddle>   <b> 添加管理员 </b> </p>
<asp:GridView   ID= "GridView1 "   BorderWidth= "0px "   runat= "server "   AllowPaging= "True "   AutoGenerateColumns= "False "   CellPadding= "1 "   CellSpacing= "1 "   Width= "100% "   OnRowDataBound= "GridView1_RowDataBound "   OnRowDeleting= "GridView1_RowDeleting ">
        <Columns>
                <asp:BoundField   HeaderText= "ID "   DataField= "Aid "   />
                <asp:BoundField   HeaderText= "帐号 "   DataField= "Account "   />
                <asp:BoundField   HeaderText= "密码 "   DataField= "Password "   />
                <asp:BoundField   HeaderText= "姓名 "   DataField= "Aname "   />
                <asp:BoundField   HeaderText= "联系方式 "   DataField= "Contacts "   />
                <asp:BoundField   HeaderText= "加入时间 "   DataField= "AddTime "   />
                <asp:TemplateField   HeaderText= "管理 "   InsertVisible= "False "   ShowHeader= "False ">
                        <ItemTemplate>
                                <asp:LinkButton   ID= "LinkButton1 "   runat= "server "   CausesValidation= "False "   CommandName= "Edit "
                                        Text= "编辑 "> </asp:LinkButton>
                                <asp:LinkButton   ID= "LinkButton2 "   runat= "server "   CausesValidation= "False "   CommandName= "Delete "
                                        Text= "删除 "> </asp:LinkButton>


                        </ItemTemplate>
                </asp:TemplateField>
        </Columns>
        <HeaderStyle   CssClass= "fonts "   HorizontalAlign= "Left "   />
</asp:GridView>
</td>
        <td   width= "1 "   class= "backs "> </td>
    </tr>
    <tr> <td   colspan= "4 "   style= "width:   600px "> <img   src= "style/images/photodown.gif "   width= "100% "   height= "10 "   style= "height:   9px "> </td>
    </tr>
</table>


        protected   void   GridView1_RowDeleting(object   sender,   GridViewDeleteEventArgs   e)
        {
                string   id   =   GridView1.Rows[e.RowIndex].Cells[0].Text;
                throw   new   Exception( "************ ");
        }

我在aspx页中加载的这个控件.咋用不起?

[解决办法]
动态加载不要写在if(!IsPostBack)里面

热点排行