HTML CSS ASPTable被“错误”了吗?

时间:2018-09-12 14:47:35

标签: c# html css .net bootstrap-4

我试图使该表看起来像一个表,但是我不能像第一行的图片下面那样删除白色的片段:

example

HTML代码:

<%@ 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#中的代码:

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);
                }
            }
        }
    }
}

如何删除当前存在的空白/边距/边框?我尝试过在有和没有“行”类以及有和没有“ col”类的情况下进行迭代。非常感谢您抽出宝贵的时间在这里。

编辑1:我在建议的注释中举了一个例子,这是请求的例子的最少代码。

1 个答案:

答案 0 :(得分:0)

如果我正确理解您的问题。 “看起来像表”看来,您只需要将Cs“表边界表”添加到C#语法或html标记中。这将为您提供桌子的外观,而不是图像显示的空白。希望这会有所帮助。