使用这里发布的示例,我一切正常。问题在于风格。当网格视图加载时,它看起来很棒。我按编辑,字体、列高、宽度等都发生了变化。当按下 EDIT 按钮时,如何编辑样式,使其在加载时看起来与以前的样式完全相同?
<asp:GridView ID="GridView1" runat="server" DataKeyNames="CustomerId" OnRowDataBound="OnRowDataBound" OnRowEditing="OnRowEditing" OnRowCancelingEdit="OnRowCancelingEdit" OnRowUpdating="OnRowUpdating" OnRowDeleting="OnRowDeleting" EmptyDataText="No records has been added." AutoGenerateEditButton="true" AutoGenerateDeleteButton="true">
</asp:GridView>
您可以使用网格视图本身:
<asp:GridView ID="GridView1" runat="server">
<EditRowStyle BackColor="Green" />
</asp:GridView>
将网格视图与样式表一起使用:
<asp:GridView ID="GridView1" runat="server">
<EditRowStyle CssClass="myClass" />
</asp:GridView>
或使用样式表:
#GridView1 input { width: 100%; }