Customize GridView Appearance in ASP.NET

After using the examples provided at this link, I was able to get everything working smoothly. However, the issue I'm facing now is with the style of the GridView. When the gridview first loads, it looks perfect. But when I click on the Edit button, the font, column height, width, and other styles change. How can I ensure that the style remains consistent when the EDIT button is pressed, similar to how it looks when initially loaded?

<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>

Answer №1

One option is to customize the gridview itself:

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

Another approach is to style the gridview using a stylesheet:

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

You can also apply styles using a simple CSS rule:

#GridView1 input { width: 100%; }

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the method for rotating a map using JavaScript?

My map built with Leaflet displays a route and a moving car marker. Now, I am looking to implement a feature where the map rotates based on the direction of the car. I have access to both the current coordinates of the car and the target coordinates. ...

Tips for identifying and retrieving the checkbox and select box values in ASP.NET

I am trying to figure out how to detect the selected checkbox values and select box entries in my registration form. Here is the select: <p><label for="favorite">Favorite Player</label> <select name = "favor"> <o ...

Achieving auto-height for two elements with CSS within a single block

I am attempting to combine two blocks into one fixed-height block in order to achieve the following design: ------------------------ UL (starts with height=0), expands when elements are added until maximum height is reached scroll bar should appear aft ...

Arranging items in a semi-circular formation around the color Blue in a precise manner

I have a character named Blue (who is blue) and I would like to place some elements in a half-circle around him. Each element will consist of an image and a text span positioned below the image. My current attempt results in the elements rotating incorre ...

Distance between two lines within a table cell is larger than expected after inserting an image - XHTML/CSS

I have a table created in XTMl, and within one of the cells I have two lines of text: Firstname Surname I want to add an image to the right of these lines. However, when I try to insert the image using <img>, there ends up being a gap between the t ...

Using ASP.NET to include a file during the Page_Load event

I have successfully developed an ASP.NET intranet site with a mechanism to check user access levels for each page. This verification code is implemented within the Page_Load event of every page where restrictions are necessary. The following code snippet ...

Security Error when using the JavaScript map function in FireFox

My current dilemma involves using a JavaScript code to extract the above-the-fold CSS from my websites. Surprisingly, it functions flawlessly on Google Chrome. However, when I attempt to execute it on Firefox, an infamous 'SecurityError' occurs: ...

Implementing CSS styles with the className attribute in a Material UI component within a ReactJS application sourced from a dynamic JSON object

I have a dynamic JSON object that includes a button element. I am using createElement and Material UI to display the data from this object. I wanted to add custom CSS styling to the button component using className, but I've been struggling to achiev ...

Styling the large drop-down menu for Internet Explorer 7

Check out the code snippet at http://jsfiddle.net/jN5G4/1/ Is there a way to align the drop-down menu for "5 Columns" to match the alignment of the other drop-downs? After removing the <a href...> </a> tags from the 5 Columns list item, the d ...

Setting the navigation bar <li> elements to active in PLAY framework using Twitter Bootstrap

Hey, I currently have a navbar in my home.scala.html that looks like this: <ul class="nav nav-justified"> <li><a href="@routes.Application.apps()">@Messages("views.main.apps")</a></li> <li ><a href="#">@Messages( ...

reason behind text styling: thick 12 pixels height with line spacing of 25 pixels using "Arial" font

Question about CSS Size: Understanding font sizes in CSS {font: 14px/24px Arial, Helvetica, sans-serif} I've noticed some CSS code like this on the website .selector {font: bold 12px/25px "Arial";} I know that 'bold' refers to font w ...

Vertical alignment issue with icons in Bootstrap 5 HTML code

Just starting out with Css and I'm having trouble aligning the google icon vertically in the center with some padding from the bottom. You can see the issue in the attached file. The text is aligned in the center. .g-icon{ background-image: url(" ...

Issue with IE 8 compatibility and jquery

Here is the setup of my div: <div class="container"> <div id="myid" style="display:hidden;"> <p>some stuff here</p></div> </div> When I run the command $("myid").slideToggle("slow"); on the above html code (where " ...

Using jQuery to remove all inline styles except for a specific one

Just a quick inquiry: Our Content Management System (CMS) utilizes CKEditor for clients to modify their websites. The front-end styles include the use of a pre tag, which we have customized to our desired appearance. However, when their team members copy a ...

I am struggling to find the right way to center those images

https://i.sstatic.net/aRkvl.jpg Hello everyone, I'm currently attempting to set up the main content of the homepage resembling the image provided, but I'm encountering some challenges. Every approach I take seems to cause the image to overflow ...

Drop-Menu - Tubular Formation of Columns

I am currently facing a challenge in creating a filter on a web page using Bootstrap's drop-down menu. The issue lies in placing the filters in columns side by side, as they are stacking up instead. The filter menu is generated dynamically by looping ...

Changes made in the edit view are not being properly saved to the database

Recently, I encountered an issue with errors in my edit view, but I managed to resolve it by following this post. Now, I am facing another challenge with updating from my MVC view. Despite making updates, the changes are not reflected in the database. Belo ...

Creating a Distinct Interior Array Separate from the Exterior

I'm currently working on a project that involves creating a 2D array. I want the interior elements of this array to be black while the exterior elements should be white. However, my 2D array doesn't seem to be forming correctly - it looks more li ...

In certain cases, Bootstrap Grid may initiate a new row from the right side

Occasionally, when the last grid height differs from the others, a new grid will start from the right side in the next row. This is illustrated clearly in the image below. https://i.sstatic.net/Kjj25.jpg I have implemented <div class="col-xs-6 col-sm- ...

The alignment of the floating left element is creating conflicts with the styling of other div

As I embark on a design project, I find myself juggling three divs for distinct products, alongside a payment method image div and a copyright div. The product divs are aligned to the left within their specific wrapper, ensuring they center and display sea ...