Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable inline editing in GridView?

Tags:

c#

asp.net

I am using ASP.NET C# Grid View, i want to edit data in control which display on same page. but when i wrote grid view row editing event it display text boxes in grid view row, Can any one help me how to disable inline editing in grid view using rowediting event?

<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>
like image 413
MindFresher Avatar asked Dec 22 '12 08:12

MindFresher


1 Answers

I had the same problem, and by a little struggling I found out that the problem was on the CommandNames in my case.

I changed Edit to edt and Delete to del, and since then the gridViewName_RowEditing event never fired again.

like image 91
Mahdi Tahsildari Avatar answered Sep 20 '22 23:09

Mahdi Tahsildari