Reputation: 740
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>
Upvotes: 5
Views: 5631
Reputation: 13582
I had the same problem, and by a little struggling I found out that the problem was on the CommandName
s in my case.
I changed Edit to edt and Delete to del, and since then the gridViewName_RowEditing
event never fired again.
Upvotes: 5
Reputation: 169
Remove <EditItemTemplate></EditItemTemplate>
from the grid view <asp:TemplateField></asp:TemplateField>
.
Upvotes: 3
Reputation: 3591
Will you try using below link
http://csharpdotnetfreak.blogspot.no/2008/12/hide-gridview-columns-in-normal-mode.html?m=1
Upvotes: 0