日期:2014-05-17  浏览次数:20518 次

一个很奇怪的问题,GridView修改出现文本框
在一个页面有一个GridView绑定数据,GridView里有一修改列<asp:ButtonField HeaderText="修改" Text="修改" CommandName="Edit" ItemStyle-Width= "40px" /> ,点击”修改“ 在本页的TextBox里显示当前列的名字,如下图:



问题是,如果我点完修改(GridView里的修改),在点下修改(GridView里的修改),在GridView列里会出现文本框 - -!如下图



下面是代码只是GridView的代码
.aspx

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"  DataKeyNames="id"
            CssClass="GridView" Width="500px"
            OnRowCommand="GridView1_RowCommand"
            onrowediting="GridView1_RowEditing" 
            onrowdatabound="GridView1_RowDataBound">
        <Columns>
            <asp:BoundField HeaderText="序号" 
                ItemStyle-Width="30px" >
<ItemStyle Width="30px"></ItemStyle>
            </asp:BoundField>
            <asp:BoundField DataField="id" HeaderText="ID" ReadOnly="True" Visible="False">
            <ItemStyle Width="30px" />
            </asp:BoundField>
            <asp:BoundField DataField="sort1" HeaderText="一级分类" 
                ItemStyle-Width="80px" >
            </asp:BoundField>
            <asp:BoundField DataField="name" HeaderText="二级分类" ReadOnly="True">
            <ItemStyle Width="80px" />
            </asp:BoundField>
            <asp:ButtonField HeaderText="修改" Text="修改" CommandName="Edit"  
                ItemStyle-Width= "40px" >
<ItemStyle Width="40px"></ItemStyle>
            </asp:ButtonField>
            <asp:TemplateField ShowHeader="False" HeaderText="删除">
                            <ItemTemplate>
                                <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" 
      &nb