How to align text string header and data bound value in Listview

peter liles 556 Reputation points
2024-02-05T15:08:05.6966667+00:00
Instead of using tables i have added  Div container to separate elements into associated content.
Using css Flex how may i align span and label elements into a two separate columns. So that they align, with equal spaces between to fill Box size. 


e.g 
	InvoiceNumber		13456
	
	UserID				Peter

<div class="Box" >
  
<span class="First">InvoiceNumber:</span>    
                <asp:Label CssClass="selected" ID="InvoiceNumberLabel" runat="server" Text='<%# Eval("InvoiceNumber") %>' />
    <span class="First">UserID:</span>  <asp:Label CssClass="selected" ID="UserIDLabel" runat="server" Text='<%# Eval("UserID") %>' />

....

</div>
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,453 questions
{count} votes

Accepted answer
  1. Lan Huang-MSFT 29,171 Reputation points Microsoft Vendor
    2024-02-06T02:22:40.15+00:00

    Hi @peter liles,

    You can use the newline character <br/> to achieve line breaks, and then you can convert the <span> into a block-level element and then adjust it.

     <div class="Box">
         <span class="First">InvoiceNumber:</span>
         <asp:Label CssClass="selected" ID="InvoiceNumberLabel" runat="server" Text='<%# Eval("InvoiceNumber") %>' />
         <br />
         <span class="First">UserID:</span>
         <asp:Label CssClass="selected" ID="UserIDLabel" runat="server" Text='<%# Eval("UserID") %>' />
         <br />
     </div>
    
    <style>
        .First {
            width: 100px;
            display: inline-block;
            padding: 5px;
        }
    </style>
    

    Result: User's image

    Best regards,
    Lan Huang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.