如何在GridView中禁用内联编辑? [英] How to disable inline editing in GridView?

查看:197
本文介绍了如何在GridView中禁用内联编辑?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ASP.NET C#网格视图,我想编辑控制,显示同一页上的数据。但是,当我写的网格视图行编辑事件它的网格视图行显示的文本框,任何一个可以帮助我如何使用rowediting事件网格视图来禁用内联编辑?

 < ASP:GridView控件ID =gvItems=服务器的AutoGenerateColumns =FALSEAllowPaging =真
            边框样式=固体边框宽度=1px的CELLPADDING =4前景色=#333333网格=无
            OnPageIndexChanging =gvItems_PageIndexChanging宽度=901px
            OnRowCommand =gvItems_RowCommandOnSelectedIndexChanged =gvItems_SelectedIndexChangedOnRowDataBound =gvItems_RowDataBoundOnRowEditing =gvItems_RowEditing>
            < AlternatingRowStyle背景色=白/>
            <柱体和GT;
                < ASP:ButtonField字段文本=编辑的CommandName =更改/>
                < ASP:ButtonField字段文本=加数的CommandName =加数/>
                < ASP:BoundField的数据字段=项ID的HeaderText =ID/>
                < ASP:BoundField的数据字段=项目的HeaderText =项目SORTEX pression =工程/>
                < ASP:BoundField的数据字段=类型的HeaderText =输入/>
                < ASP:BoundField的数据字段=释放的HeaderText =释放/>
                < ASP:BoundField的数据字段=优先级的HeaderText =优先级/>
                < ASP:BoundField的数据字段=严重性的HeaderText =严重性/>
                < ASP:BoundField的数据字段=客户的HeaderText =客户/>
                < ASP:BoundField的数据字段=状态的HeaderText =状态/>
                < ASP:BoundField的数据字段=主题的HeaderText =主题/>
                < ASP:BoundField的数据字段=CreatedDateDataFormatString ={0:D}的HeaderText =创建日期/>                < ASP:的TemplateField>
                    <&ItemTemplate中GT;
                        <! - 要发射的OnRowEditing事件.-- GT&;
                        < ASP:LinkBut​​ton的ID =lbView=服务器的CommandName =查看
                            文字=查看CommandArgument =<%#Container.DataItemIndex%GT;>
                        < / ASP:LinkBut​​ton的>
                      < ASP:HiddenField =服务器ID =hdnItemID值='<%#的eval(项目编号)%>'>
                                    < / ASP:HiddenField>
                    < / ItemTemplate中>
                < / ASP:的TemplateField>
            < /专栏>            < FooterStyle背景色=#990000FONT-粗体=真前景色=白/>
            < HeaderStyle背景色=#990000FONT-粗体=真前景色=白Horizo​​ntalAlign =左/>
            < PagerSettings模式=NumericFirstLast/>
            < PagerStyle背景色=#FFCC66前景色=#333333Horizo​​ntalAlign =中心/>
            < RowStyle的BackColor =#FFFBD6前景色=#333333/>
            < SelectedRowStyle背景色=#FFCC66FONT-粗体=真前景色=海军/>
            < SortedAscendingCellStyle背景色=#FDF5AC/>
            < SortedAscendingHeaderStyle背景色=#4D0000/>
            < SortedDescendingCellStyle背景色=#FCF6C0/>
            < SortedDescendingHeaderStyle背景色=#820000/>
        < / ASP:GridView的>


解决方案

我有同样的问题,并通过一点点挣扎,我发现,这个问题是在的CommandName 在我的情况。

我改的修改 EDT 删除删除,然后自此 gridViewName_RowEditing 事件不会再开枪。

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>

解决方案

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.

这篇关于如何在GridView中禁用内联编辑?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆