0

我数据库中的一个字段可能包含数百甚至数千个单词。我想知道如何使 gridview 中的编辑按钮作为一个动作事件工作,但同时也关闭它的其余自动功能。我的意思是我不希望表格中的实际单元格可编辑,也不希望更新和取消按钮可见。

这是网格视图:

   <asp:Panel ID="updatePanel" runat="server" Visible="false">
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource4"
            AllowPaging="True" BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None"
            BorderWidth="1px" CellPadding="3" CellSpacing="2" OnRowDeleting="GridView1_OnRowDeleting" OnRowEditing="GridView1_OnRowEditing" 
            DataKeyNames="PK_DailyTaskHours, PK_NonScrumStory">
            <Columns>
                <asp:BoundField DataField="Catagory" HeaderText="Support Catagory" SortExpression="Catagory" />
                <asp:BoundField DataField="AppName" HeaderText="Application Name" SortExpression="IncidentNumber" />
                <asp:BoundField DataField="IncidentNumber" HeaderText="Incident #" SortExpression="IncidentNumber" />
                <asp:BoundField DataField="Hours" HeaderText="Hours" SortExpression="Hours" />
                <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
                <asp:BoundField DataField="CreatedDate" HeaderText="Created Date" SortExpression="CreatedDate" />
                <asp:CommandField ShowEditButton="True" />
                <asp:CommandField ShowDeleteButton="True" />
            </Columns>
            <FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
            <HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
            <PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
            <RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
            <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
            <SortedAscendingCellStyle BackColor="#FFF1D4" />
            <SortedAscendingHeaderStyle BackColor="#B95C30" />
            <SortedDescendingCellStyle BackColor="#F1E5CE" />
            <SortedDescendingHeaderStyle BackColor="#93451F" />
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource4" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
            SelectCommand="SELECT [NonScrumStory].[IncidentNumber], [NonScrumStory].[Description], [NonScrumStory].[CreatedDate], 
            [DailyTaskHours].[Hours], [Application].[AppName], [SupportCatagory].[Catagory], [DailyTaskHours].[PK_DailyTaskHours], 
            [NonScrumStory].[PK_NonScrumStory] FROM [NonScrumStory], [DailyTaskHours], [Application], [SupportCatagory] WHERE 
            ([NonScrumStory].[UserId] = @userIdSelected) AND ([NonScrumStory].[PK_NonScrumStory] = [DailyTaskHours].[NonScrumStoryId]) 
            AND ([NonScrumStory].[CatagoryId] = [SupportCatagory].[PK_SupportCatagory]) AND 
            ([NonScrumStory].[ApplicationId] = [Application].[PK_Application]) AND ([NonScrumStory].[Deleted] != 1)"
            DeleteCommand="UPDATE [NonScrumStory] SET [Deleted] = 1 WHERE (PK_NonScrumStory = @nonScrumStoryPK); 
            UPDATE [DailyTaskHours] SET [Deleted] = 1 WHERE (PK_DailyTaskHours = @dailyTaskHoursPK); ">
            <SelectParameters>
                <asp:QueryStringParameter Name="userIdSelected" Type="String" />
            </SelectParameters>
            <DeleteParameters>
                <asp:QueryStringParameter Name="dailyTaskHoursPK" Type="String" />
                <asp:QueryStringParameter Name="nonScrumStoryPK" Type="String" />
            </DeleteParameters>
        </asp:SqlDataSource>

此外,我有动作事件工作:

protected virtual void GridView1_OnRowEditing(object sender, GridViewEditEventArgs e)
{

}

而且我知道 usingReadOnly="false"可以防止单元格变得可编辑。如何摆脱更新/取消?是否可以立即执行取消以使用户看不到更改?当用户按下编辑时,显示网格视图的面板将变得不可见,并且将出现一个带有编辑选项的新面板。

4

0 回答 0