2012-12-22 66 views
4

我正在使用ASP.NET C#Grid View,我想編輯顯示在同一頁面上的控件中的數據。但是當我寫網格視圖行編輯事件它顯示網格視圖行中的文本框,任何人可以幫助我如何禁用使用rowediting事件的網格視圖內聯編輯?如何在GridView中禁用內聯編輯?

<asp:GridView ID="gvItems" runat="server" AutoGenerateColumns="False" AllowPaging="True" 
      BorderStyle="Solid" BorderWidth="1px" CellPadding="4" ForeColor="#333333" GridLines="None" 
      OnPageIndexChanging="gvItems_PageIndexChanging" Width="901px" 
      OnRowCommand="gvItems_RowCommand" OnSelectedIndexChanged="gvItems_SelectedIndexChanged" OnRowDataBound="gvItems_RowDataBound" OnRowEditing="gvItems_RowEditing"> 
      <AlternatingRowStyle BackColor="White" /> 
      <Columns> 
       <asp:ButtonField Text="Edit" CommandName="Change" /> 
       <asp:ButtonField Text="Addend" CommandName="Addend" /> 
       <asp:BoundField DataField="ItemID" HeaderText="ID" /> 
       <asp:BoundField DataField="Project" HeaderText="Project" SortExpression="Project" /> 
       <asp:BoundField DataField="Type" HeaderText="Type" /> 
       <asp:BoundField DataField="Release" HeaderText="Release" /> 
       <asp:BoundField DataField="Priority" HeaderText="Priority" /> 
       <asp:BoundField DataField="Severity" HeaderText="Severity" /> 
       <asp:BoundField DataField="Client" HeaderText="Client" /> 
       <asp:BoundField DataField="Status" HeaderText="Status" /> 
       <asp:BoundField DataField="Subject" HeaderText="Subject" /> 
       <asp:BoundField DataField="CreatedDate" DataFormatString="{0:d}" HeaderText="Created Date" /> 

       <asp:TemplateField> 
        <ItemTemplate> 
         <!--To fire the OnRowEditing event.--> 
         <asp:LinkButton ID="lbView" runat="server" CommandName="View" 
          Text="View" CommandArgument="<%# Container.DataItemIndex %>"> 
         </asp:LinkButton> 
         <asp:HiddenField runat="server" ID="hdnItemID" Value='<%#Eval("ItemID") %>'> 
            </asp:HiddenField> 
        </ItemTemplate> 
       </asp:TemplateField> 
      </Columns> 

      <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" /> 
      <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" HorizontalAlign="Left" /> 
      <PagerSettings Mode="NumericFirstLast" /> 
      <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" /> 
      <RowStyle BackColor="#FFFBD6" ForeColor="#333333" /> 
      <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" /> 
      <SortedAscendingCellStyle BackColor="#FDF5AC" /> 
      <SortedAscendingHeaderStyle BackColor="#4D0000" /> 
      <SortedDescendingCellStyle BackColor="#FCF6C0" /> 
      <SortedDescendingHeaderStyle BackColor="#820000" /> 
     </asp:GridView> 
+0

我們可以看到您嘗試過的代碼,以便我們可以幫助您 – Seany84

+0

命令調用的隱藏代碼是什麼。正如我所看到的,命令調用不會激活iniline編輯。 – Aristos

回答

4

我有同樣的問題,並通過一點努力,我發現問題是在我的情況下CommandName s。

我改變編輯EDT刪除德爾,自那時以來,gridViewName_RowEditing事件不會再發射。

3

從網格視圖<asp:TemplateField></asp:TemplateField>刪除<EditItemTemplate></EditItemTemplate>

+0

我沒有使用編輯模板.. – MindFresher

相關問題