无法将溢出属性添加到 ASP.NET 日历中某一天的单元格

Can't add the overflow attribute to the cell of a day in the ASP.NET calendar

提问人:jimmy_couillard 提问时间:11/10/2023 最后编辑:marc_sjimmy_couillard 更新时间:11/10/2023 访问量:25

问:

我不知道为什么,但是,当我在日历的特定日期添加一些标签时,单元格高度变得比我在 css 中放置的要大。首先,我尝试将值连接起来,并将其放在一个标签中,然后将其添加到当天的单元格中,但没有结果。因此,现在我正在为当天单元格中网格视图中的每一行添加一个标签。

ASPX文件:

<%@ Page Title="Home Page" Language="VB" 
    MasterPageFile="~/Site.Master" AutoEventWireup="true" 
    CodeBehind="Default.aspx.vb" Inherits="TeleReception._Default" %>

<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">

    <asp:Panel ID="PanelAll" runat="server" HorizontalAlign="Center" Width="130%" CssClass="PanelCalendar">
        <asp:Calendar ID="Calendar1" runat="server" Width="100%" Height="850px" Font-Names="Verdana" BackColor="White" BorderColor="White" BorderWidth="1px" Font-Size="9pt" ForeColor="Black" NextPrevFormat="FullMonth" OnDayRender="Calendar1_DayRender">
            <DayHeaderStyle Font-Bold="True" Font-Size="8pt" />
            <DayStyle HorizontalAlign="Left" VerticalAlign="Top" CssClass="DayStyle" />
            <NextPrevStyle Font-Bold="True" Font-Size="16pt" ForeColor="#333333" VerticalAlign="Bottom" CssClass="NextPrevStyle" />
            <OtherMonthDayStyle ForeColor="#333333" />
            <SelectedDayStyle BackColor="#00A55E" ForeColor="White" />
            <TitleStyle BackColor="White" BorderColor="Black" BorderWidth="4px" Font-Bold="True" Font-Size="20pt" ForeColor="#00A55E"  />
            <TodayDayStyle BackColor="#00a55e" ForeColor="white" />
            <WeekendDayStyle BackColor="#EAEAEA" />
        </asp:Calendar>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" Visible="false">
            <Columns>
                <asp:BoundField DataField="Document No_" HeaderText="Document No_" SortExpression="Document No_" />
                <asp:BoundField DataField="Location Code" HeaderText="Location Code" SortExpression="Location Code" />
                <asp:BoundField DataField="Pay-to Name" HeaderText="Pay-to Name" SortExpression="Pay-to Name" />
                <asp:BoundField DataField="No_" HeaderText="No_" SortExpression="No_" />
                <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
                <asp:BoundField DataField="Quantity" HeaderText="Quantity" SortExpression="Quantity" />
                <asp:BoundField DataField="Unit of Measure Code" HeaderText="Unit of Measure Code" SortExpression="Unit of Measure Code" />
                <asp:BoundField DataField="Expected Receipt Date" HeaderText="Expected Receipt Date" SortExpression="Expected Receipt Date" />
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:bc365_prodConnectionString %>"></asp:SqlDataSource>

        <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource2" Visible="false">
            <Columns>
                <asp:BoundField DataField="Document No_" HeaderText="Document No_" SortExpression="Document No_" />
                <asp:BoundField DataField="Transfer-from Code" HeaderText="Transfer-from Code" SortExpression="Transfer-from Code" />
                <asp:BoundField DataField="Transfer-to Code" HeaderText="Transfer-to Code" SortExpression="Transfer-to Code" />
                <asp:BoundField DataField="Item No_" HeaderText="Item No_" SortExpression="Item No_" />
                <asp:BoundField DataField="SOL No2Soleno" HeaderText="SOL No2Soleno" SortExpression="SOL No2Soleno" />
                <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
                <asp:BoundField DataField="Quantity" HeaderText="Quantity" SortExpression="Quantity" />
                <asp:BoundField DataField="Unit of Measure Code" HeaderText="Unit of Measure Code" SortExpression="Unit of Measure Code" />
                <asp:BoundField DataField="Receipt Date" HeaderText="Receipt Date" SortExpression="Receipt Date" />
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:bc365_prodConnectionString %>"></asp:SqlDataSource>
    </asp:Panel>
</asp:Content>

我的 vb 代码中的事件处理程序:Dayrender

Protected Sub Calendar1_DayRender(sender As Object, e As DayRenderEventArgs)
    e.Cell.CssClass = "DayCellStyle"
    'To Show the Po
    Dim aLabel As Label = New Label()
    Dim ADate As Date = e.Day.Date
    For i As Integer = 0 To GridView1.Rows.Count - 1
        Dim PoDate As Date = GridView1.Rows(i).Cells(7).Text
        If ADate = PoDate Then
            Dim PoNo = GridView1.Rows(i).Cells(0).Text
            Dim PoLocationCode As String = GridView1.Rows(i).Cells(1).Text
            Dim PoPayToName As String = GridView1.Rows(i).Cells(2).Text
            Dim PoItemNo As String = GridView1.Rows(i).Cells(3).Text
            Dim PoDescription As String = GridView1.Rows(i).Cells(4).Text
            Dim PoQuantity = Math.Round(Convert.ToDecimal(GridView1.Rows(i).Cells(5).Text), 2)
            Dim PoUnitMeasureCode As String = GridView1.Rows(i).Cells(6).Text
            aLabel.Text = aLabel.Text + "<br>" + "<br>" + "-" + PoNo + " = " + PoLocationCode + " / " + PoPayToName + " ( " + PoItemNo + " / " + PoDescription + " ) " + PoQuantity.ToString + " * " + PoUnitMeasureCode
            e.Cell.Controls.Add(aLabel)
        End If
    Next
    'To Show the TR
    For j As Integer = 0 To GridView2.Rows.Count - 1
        Dim TrDate As Date = GridView2.Rows(j).Cells(8).Text
        If ADate = TrDate Then
            Dim TrNo = GridView2.Rows(j).Cells(0).Text
            Dim TrFromCode = GridView2.Rows(j).Cells(1).Text
            Dim TrToCode = GridView2.Rows(j).Cells(2).Text
            Dim TrItemNo = GridView2.Rows(j).Cells(3).Text
            Dim TrItem2No = GridView2.Rows(j).Cells(4).Text
            Dim TrDescription = GridView2.Rows(j).Cells(5).Text
            Dim TrQuantity = Math.Round(Convert.ToDecimal(GridView2.Rows(j).Cells(6).Text), 2)
            Dim TrUnitOfMeasureCode = GridView2.Rows(j).Cells(7).Text

            Dim bLabel As Label = New Label()
            bLabel.Text = bLabel.Text + "<br>" + "<br>" + "-" + TrNo + " = " + TrFromCode + " / " + TrToCode + " ( " + TrItemNo + " / " + TrItem2No + " (" + TrDescription + ")) " + TrQuantity.ToString + " * " + TrUnitOfMeasureCode
            bLabel.Font.Size = FontUnit.Point(5)
            e.Cell.Controls.Add(bLabel)
        End If
    Next
End Sub

还有我的CSS

body {
}

.PanelCalendar{
    margin: 0% -15% 0% -15%;
}
.DayStyle {
    padding: 10px;
    height: 141px;
    max-height: 141px;
    overflow: auto;
}

.aLabelStyle {
    padding: 10px;
    font-weight: bold;
    height: 141px;
    overflow: auto;
}

.DayCellStyle {
    height: 141px;
    padding: 10px;
    font-weight: bold;
    font-size: 10px;
    overflow: auto;
}

我只希望一天的高度为 141px,如果单元格中的标签超过高度,则添加一个滚动条。

asp.net vb.net 日历

评论


答: 暂无答案