Is your HTML CSS ASPTable experiencing some glitches?

I'm struggling to style this table to look more like a traditional table. The issue I'm facing is removing the unwanted white space in the first row as shown in the image below:

HTML code snippet:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="testmain.aspx.cs" Inherits="XRSTest.testmain" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <link href="css/bootstrap.css" rel="stylesheet" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
</head>
<body>
    <form id="form1" runat="server" style="background-color: white">
        <div class="container mt-1">
            <div class="row">
                <div class="col-8 mt-5 d-inline flex-column h-100 border border-success" style="background-color: lightyellow">
                    Some content
                </div>
                <div id="Info" class="col-4 mt-5 d-inline d-flex flex-column h-100 justify-content-center border border-success" style="background-color: lightgray" runat="server">
                <div class="container">
                    <div class="row">
                            <asp:Table runat="server" ID="PriceInc" class="container bg-white mt-5 mb-3" Style="font-size: 12px;">
                                <asp:TableRow CssClass="bg-primary row" style="font-size: 12px;">
                                    <asp:TableCell>
                                    Incluídos en precio final
                                        </asp:TableCell>
                                </asp:TableRow>
                            </asp:Table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
</body>
</html>

C# code snippet:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace XRSTest
{
    public partial class testmain : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            DataColumn col1 = new DataColumn();
            col1.ColumnName = "col1";
            DataColumn col2 = new DataColumn();
            col2.ColumnName = "col2";
            DataColumn col3 = new DataColumn();
            col3.ColumnName = "col3";

            DataTable charges = new DataTable();
            charges.Columns.Add(col1);
            charges.Columns.Add(col2);
            charges.Columns.Add(col3);

            DataRow rows = charges.NewRow();
            rows["col1"] = "ID";
            rows["col2"] = "description";
            rows["col3"] = "0.0";
            charges.Rows.Add(rows);

            DataRow asd = charges.NewRow();
            asd["col1"] = "ID2";
            asd["col2"] = "otherdescript";
            asd["col3"] = "0.1";
            charges.Rows.Add(asd);

            foreach (DataRow row in charges.Rows)
            {
                TableCell inc = new TableCell();
                if (float.Parse(row.Field<string>(2).Replace(".", ",")) < 1)
                {
                    inc.Text = "incluído";
                    inc.Attributes.Add("class", "col-4 justify-content-end");
                    TableRow n = new TableRow();
                    TableCell name = new TableCell();
                    name.Text = "some text";
                    name.Attributes.Add("class", "col-8");
                    n.Cells.Add(name);
                    n.Cells.Add(inc);
                    PriceInc.Rows.Add(n);
                }
            }
        }
    }
}

How can I eliminate that unnecessary white space/margin/border in the table? I've experimented with different classes and styles without success. Your help is greatly appreciated.

EDIT1: As per a comment suggestion, I have provided a basic example code for reference.

Answer №1

If I'm interpreting your inquiry correctly, in order to make something appear as a table, you simply need to incorporate the CSS classes "table" and "table-bordered" into either your C# syntax or HTML markup. By doing so, you will achieve the desired table-like appearance instead of the blank space depicted in your image. I trust this information proves useful.

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

Ways to showcase a textbox input in different DIVs multiple times

I am struggling to showcase the content of a textarea within multiple div elements when a user inputs text. The value only appears in the first div, but I want it to display in every div. Here is my HTML and jQuery code: <input type="textarea" id="my ...

Updating the class of a div based on a checkbox being checked or unchecked

I am attempting to apply the "isChecked" class to the parent div when a checkbox is checked, using the ngClass directive. Here is the HTML: <div ng-class="{isChecked: (isChecked_1 == 'true')}"> <input type="checkbox" id="check_ ...

What is the best way to horizontally center a div while ensuring the content within the div stays aligned?

I'm attempting to align a div in the center while maintaining the position of its contents. Check out my code snippet: <style> .wrap{ position: relative; } .character{ position: absolute; bottom: -10%; left: 0; heigh ...

Bug in Click Behavior of HTML5 Canvas on Webkit Browser Versions Below 535 for Android Native and iOS5 Safari

Recently, I encountered a peculiar bug in Android where positioning a canvas element on the Native Android Browser (WebKit 534.4) using css position:absolute; top:10px; left:100px; resulted in the duplicated Canvas being rendered to the browser while ignor ...

Issue with ng-model causing incorrect variable binding

My issue lies with a variable that I have connected to a select input through the use of ng-model. Strangely, the variable seems to not update with the correct data and retains the value assigned to it during initialization. I have a similar setup elsewhe ...

Initial button click fails to trigger onclick event

After researching and reading various articles on the issue, I have tried several solutions but nothing seems to work. The problem occurs when the button is clicked for the first time - nothing happens. It is only after clicking the button a second time th ...

Error in C# Collection due to file reading with corrupted text

I am a beginner with C# and have been tasked with creating a custom task in a plugin for our deployment software. However, I am struggling to understand the process. My goal is to log data from a specific directory on my deployment server to the output log ...

Even after disposing of the IE driver, the IEDriverServer.exe process remains stuck

Currently, I am utilizing Selenium's IE driver for conducting web testing. However, I am encountering an issue where after launching and closing IE8, the IEDriverServer.exe process remains active. Subsequently, if I attempt to run the test again, a ne ...

What strategies can I employ to prevent my div tags from shifting positions relative to each other?

I spent time formatting a div tag for my main content and then placed that div inside another wrapper div. However, when I tried to add my logo to the site, everything shifted. It appeared as though the div containing the logo had pushed the wrapper down. ...

Having issues with Firefox rendering JavaScript and CSS correctly

I'm trying to figure out if it's the row class from Bootstrap that's causing issues, or if there's a problem with my JS/CSS not loading properly in Firefox. It seems to be working fine in Chrome and Safari. Any ideas on what could be go ...

What's the best way to ensure images and videos in a div maintain their aspect ratio when resizing?

Is there a way to make the image and video fit inside the div without altering the aspect ratio? The code snippet below is what gets displayed on my website, utilizing bootstrap for responsiveness. <div id="micropost-208"> <di ...

How can you effectively clear cache linked to a specific file name by utilizing DiskCache alongside the VirtualImageProvider plugin with ImageResizer.NET?

Is there a way to clear the cache for a specific file in ImageResizer.NET with the DiskCache plugin? In my project, we need to crop images and save them using the same file name to maintain integrity. Despite changing the modification time and even create ...

The issue with Scrolltop is that it is not aligning to the intended

My goal is to focus the top of a div when an anchor is clicked using the code below. $('html, body').animate({scrollTop: $("#" + divid).offset().top}, 100); Unfortunately, instead of scrolling to the top of the div, the focus ends up at a posit ...

Eliminate the focus border in React-Select

I've been struggling to remove the border or outline (not really sure which one it is) from React Select when it's focused. Here is an image for reference. As you can see, I currently have no default border: https://i.stack.imgur.com/IubaN.png ...

When placed within a <li> element, the <a> tag will not create a hyperlink to a page, but it will

I have encountered an issue with my anchor links. All of them are working properly except for the one in the second ul with an href="page1". Interestingly, the link shows the correct destination at the bottom left of my screen and works when I right-click ...

C# Number Formatting: A Guide to Properly Formatting Numbers

Can anyone help me figure out how to separate a number with commas? I've tried several methods without success. The number is already converted to a string and now I want to format the "tot" variable. GetData getData = new GetData(); string tot = Co ...

Height setting for flex column layout

.flex-body { display: flex; flex-wrap: wrap; } .flex-body div{ width: 50%; align-items: flex-start; } <div class="flex-body"> <div style="background: #0980cc; height:100px;"></div> <div style="background: #09cc69;height: 20 ...

Unable to locate element using XPATH even though it appears in the search bar console

Currently, I am working on developing a program that fills out specific sections of a Microsoft One page. My approach involves utilizing Python and selenium for this endeavor. While I can successfully access the webpage and input data in the main section, ...

Guide to converting a nested JSON object into a primitive type using the field of one of the nested objects

Consider the following JSON data: [{ "id": 123, "description": "test", "group": { "id": 456, "description": "org" } }] I am looking to deserialize the JObject into a C# object. Typically, I would approach it like this (whe ...

Utilizing clip-path polygons for effective styling on Firefox and iOS

I have been working on a plugin to create animated modal boxes by utilizing the clip-path property. However, I have encountered an issue where this code only seems to work in Chrome. You can view the codepen demo here. Unfortunately, it appears that Firef ...