gpt4 book ai didi

c# - 单击“编辑命令控件”时 GridView 样式丢失

转载 作者:行者123 更新时间:2023-11-28 10:03:25 24 4
gpt4 key购买 nike

在单击“编辑命令控件”之前,我有一个近乎完美的 GridView。然后列的宽度变宽并且极度不对齐。是什么导致了这种行为?

编辑前

enter image description here

修改后

enter image description here

编辑问题:

当单击“编辑”时,可编辑的列连接到一个 TextBox 控件,如下面的代码片段所示:

(TextBox)GridView2.Rows[e.RowIndex].Cells[7].Controls[0]

基于 this question,我有点弄清楚,当 Row_Editing 事件被触发时,样式可能没有被触发。但我不确定上面的 TextBox 控件是否也是它背后的罪魁祸首...

最佳答案

与其添加通用的 Edit/Update ,不如尝试分配图像,然后再向它们添加命令。

      <asp:TemplateField HeaderText="">
<HeaderStyle CssClass="gvProvFooterStyle" />
<ItemStyle CssClass="gvProvFooterStyle" />
<FooterStyle CssClass="gvProvFooterStyle footerRow" />
<EditItemTemplate>
<asp:ImageButton ID="ibtnUpdate" runat="server" CommandName="Update" CausesValidation="true" OnClientClick="ValidateEdt();" ValidationGroup="onUpdate" ImageUrl="~/images/abc.png" CssClass="imagebuttons ibtnStyle" />
<asp:ImageButton ID="ibtnCancel" runat="server" CommandName="Cancel" CausesValidation="false" ImageUrl="~/images/abc.png" CssClass="imagebuttons" />
</EditItemTemplate>
<ItemTemplate>
<asp:ImageButton ID="ibtnEdit" runat="server" CommandName="Edit" CausesValidation="false" ImageUrl="~/Content/Images/black-edit-24.ico" CssClass="imagebuttons ibtnStyle" />
<asp:ImageButton ID="ibtnDelete" runat="server" CommandName="Delete" CausesValidation="false" ImageUrl="~/images/abc.png" CssClass="imagebuttons" />
</ItemTemplate>
</asp:TemplateField>

然后根据您的需要分配它们的宽度。要回答您的问题,您还没有将样式应用到您的编辑元素模板,只是元素模板。

关于c# - 单击“编辑命令控件”时 GridView 样式丢失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24637995/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com