Grid Dimensions and Placement

I have been attempting to fix the alignment of each column in my fixed header table and gridview control without success. Inspecting the elements revealed that the header ID width is set correctly at 50px, but the boundfield EmpID width is incorrect at 66px. Additionally, the header for Employee displays a correct width of 150px, while the boundfield EmpName shows 200px. How can I resolve this issue and ensure each column aligns properly with the header and gridview results?

<div style="height: 30px; margin: 0; padding: 0">
    <table id="tblHeader" class=""
        style="background-color: #336666; color: white; border-collapse: collapse; height: 100%;">
        <tr>
            <td style="text-align:left;width: 50px">
                <span>ID</span>
            </td>
            <td style="text-align:left;width: 150px">
                <span>Employee</span>
            </td>
        </tr>
    </table>
</div>

<div style="height: 360px; overflow: auto;">
    <asp:GridView ID="grdEmp" runat="server" AutoGenerateColumns="False"
        OnRowCommand="grdEmp_RowCommand" ShowHeader="false"
        GridLines="None" Font-Size="Small">
        <Columns>
            <asp:BoundField DataField="EmpID" ItemStyle-Width="50px">
            </asp:BoundField>
            <asp:BoundField DataField="EmpName">
                <ItemStyle CssClass="RowStyle150"></ItemStyle>
            </asp:BoundField>
        </Columns>
        <RowStyle BackColor="White" ForeColor="#333333" />
    </asp:GridView>
</div>

.RowStyle50 {
    text-align:left;
    padding-left: 0px;
    padding-right: 0px;
    width: 50px !important;
}

.RowStyle150 {
    text-align:left;
    padding-left: 0px;
    padding-right: 0px;
    width: 150px !important;
}

Answer №1

Give this a try

<div style="height: 30px; margin: 0; padding: 0">
<table id="tblHeader" class=""
    style="background-color: #336666; color: white; border-collapse: collapse; height: 100%;">
    <tr>
        <td class="col-lg-4" style="text-align:left;width: 50px">
            <span>ID Number</span>
        </td>
        <td class="col-lg-4" style="text-align:left;width: 150px">
            <span>Employee Name</span>
        </td>
    </tr>
<tr>
 <td>
   <div style="height: 360px; overflow: auto;">
    <asp:GridView ID="grdEmp" runat="server" AutoGenerateColumns="False"
    OnRowCommand="grdEmp_RowCommand" ShowHeader="false"
    GridLines="None" Font-Size="Small">
    <Columns>

        <asp:BoundField DataField="EmployeeID" ItemStyle-Width="50px">
        </asp:BoundField>
    </Columns>
    <RowStyle BackColor="White" ForeColor="#333333" />
  </asp:GridView>
  </div>
      </td>
                 <td>
        <div style="height: 360px; overflow: auto;">
    <asp:GridView ID="grdEmp" runat="server" AutoGenerateColumns="False"
    OnRowCommand="grdEmp_RowCommand" ShowHeader="false"
    GridLines="None" Font-Size="Small">
    <Columns>
        <asp:BoundField DataField="EmployeeName">
            <ItemStyle CssClass="RowStyle150"></ItemStyle>
        </asp:BoundField>
    </Columns>
    <RowStyle BackColor="White" ForeColor="#333333" />
  </asp:GridView>
  </div>
      </td>
</tr>
</table>
</div>

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

Issue with Vue2: encountering an error with the view-router component when attempting to utilize the <router-view> tag

Currently delving into Vue2 for the first time and facing hurdles with routes. Ever since I inserted <router-view></router-view> in index.html, an exception has been popping up: [Vue warn]: Failed to mount component: template or render functi ...

Is it possible to automatically redirect to another page once two text inputs have been filled without the use of a button?

Looking to create a basic static demonstration resembling Uber, but struggling to figure out how to trigger a redirect or any kind of action once both input elements have been filled. I plan to include two input fields similar to this example and aim to a ...

The same CSS styles appear distinct when applied in Angular

I'm currently in the process of rewriting a page using Angular. I've successfully copied over all the styles and layout from the original page, but for some reason the colors aren't being applied correctly. After comparing the original and n ...

Is it possible to utilize the onClick event while preserving the use of "this" within the function it triggers?

There is a project with specific needs that require implementation. The task involves adding points to the total score when a button is clicked, without making any changes to the provided HTML code. This requires writing unobtrusive JavaScript code by atta ...

Extract CSS using PHP

Currently facing a challenge with a project where I am receiving HTML files using CURL. The issue arises when images are set as background image in the CSS, as they do not load since the images are not on my server. This requires me to adjust the CSS to co ...

Is there a way to achieve element scrolling similar to scrollLeft within a scrollable container without using JavaScript

Looking for a CSS Solution: Is there a way to achieve element.scrollLeft functionality in CSS without using javascript? I want to pre-scroll a scrollable container. Situation Overview: I have a scrollable container that houses various items. Some instanc ...

How can one appropriately utilize the counter() function in conjunction with nested headings and corresponding counter-increment() and counter-reset() methods?

I am encountering an issue with counter-reset() when introducing a div between the initial declaration and the reset. Initially, I had structured my code like this, with headings directly under the numberedHeadings class: Now, there is a need to wrap eac ...

problems arise due to padding and floating on the navigation bar

I have been facing a couple of challenges with my code. Firstly, I am trying to remove the small annoying line underneath my selected navigation links and also attempting to float both the header and footer to the right without losing their backgrounds. I ...

Tips for Utilizing Bootstrap to Create a Responsive ASP GridView

I am facing an issue with utilizing bootstrap to develop a responsive GridView. I came across an illustration on , but the main challenge is how to assign md, xs, sm, lg css classes for gridview columns with varying widths, Is there a practical approach ...

Align the text vertically in a Bootstrap button

Can anyone lend a hand with vertically aligning text in a Bootstrap button? When I use the align-middle class, the text is aligned as desired. However, if I use the align-top class, the text remains top-aligned no matter what I do. Any suggestions? Here& ...

A demonstration of VueJS Nested Builder functionality

I am currently exploring VueJS and working on a project to create a simple page builder application that allows users to add sections and subsections. I am seeking guidance on how to properly set up the Vue data property for this functionality. Any advice ...

Learn how to toggle the display of a div using jQuery, just like the functionality on the popular website

Visit Mashable here Below is the script I am currently using: $(document).ready(function(){ $(".show_hide5").mouseover(function(){ $('.selected').removeClass('selected'); $(this).next().fadeIn("slow").addClass(&apo ...

Tips for validating date input in a TextBox using JQuery on an ASP.NET platform:

Here is some code I wrote: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="datetime.WebForm1" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <tit ...

Selecting the incorrect label while hovering over a checkbox

I am using Bootstrap and encountering an issue with displaying checkboxes after clicking on an accordion element. While the first checkbox is displayed correctly, the checkboxes inside the accordion do not appear as expected. It is confusing to me why thi ...

Regular expression that can be used to extract information from a text file by filtering and returning only

When I open a text file, it contains several lines like the examples below. surname australia enter name j.jonhs enter name j.cause enter name f.london enter I am seeking assistance to modify the code snippet below so that it captures the first line m ...

Activate link by checking the 'Accept' box

I am trying to add a 'Click to Accept Terms' checkbox on my website (), which will activate a link to another page once checked. After modifying a script and HTML code that has been successful elsewhere on the internet (as seen in this JSFiddle ...

What is the best way to extract keywords from a search engine using ASP.NET?

Can anyone provide guidance on how to optimize the keywords entered in a search engine to navigate to my website using ASP.NET webforms? Your assistance is greatly appreciated. Thank you. ...

Using Azure AD front-channel logout URL and SameSite cookie with ASP.NET

After exploring the possibility of implementing Azure AD for an older web forms ASP.NET application, I encountered a roadblock when attempting to utilize single sign out via the Front-channel logout URL in the App registration. The default setup was not f ...

Type X service registration appears to be correct, yet no service has been registered as of now

Within Startup.cs of an ASP.NET Core 2.0 web project, I have some straightforward code: public async void ConfigureServices(IServiceCollection services) { services.AddMvc(); await CreateContainer(); services.AddSingleton<Infrastructure.Lo ...

Display the cost in a dynamic label that adjusts accordingly as the user modifies its value

Currently, I am facing the following issue. I am in the process of creating a form where users can choose from a selection of products they want to order. The form currently looks like this: <input type="number" class="bestelformulier" name="PizzaMaga ...