ASP编辑GridView样式

时间:2017-11-15 23:42:45

标签: css asp.net gridview styles

使用发布here的示例,我发现一切正常。问题是风格。当gridview加载时,它看起来很神奇。我按Edit,字体,列高,宽度等都改变了。如何在按下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>

1 个答案:

答案 0 :(得分:1)

您可以使用gridview本身:

<asp:GridView ID="GridView1" runat="server">
    <EditRowStyle BackColor="Green" />
</asp:GridView>

将gridview与样式表一起使用:

<asp:GridView ID="GridView1" runat="server">
    <EditRowStyle CssClass="myClass" />
</asp:GridView>

或使用样式表:

#GridView1 input { width: 100%; }