Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 6th, 2005, 08:01 AM
Registered User
 
Join Date: Jan 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Newbie help again - data display

I have 6 columns in a table -
Name, Address1, Address2, Address3, Address4, ZipCode

Each entry in the table will always have a Name but won't necessarily have a value in every Address field

What is the best way to pull this data out and display it?

I currently have 5 labels which display the values from each column like so:

Mr Jones
Floor 2
23 Some Road
Sometown
Somehere
12345

But if there is an entry which has an empty column I get an ugly space:

Mr Jones
Floor 2
23 Some Road
Sometown

12345

I can't work out how to display data from the 4 different address columns in one object so that this empty space doesn't appear.

I'm sure this is easy but I can't se hwo to do it.

 
Old January 7th, 2005, 12:27 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I'm confused... do you want to show your data in a flow layout or in a columnar layout?
 
Old January 7th, 2005, 05:31 AM
Registered User
 
Join Date: Jan 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry - I'll try and explain better. I don't want to use a column based layout like a datagrid so I'm currently doing it in a flow layout like this. I have 6 labels which are bound to the separate data fields as such:

cnConnection.Open()
dr = cmdSelectDetails.ExecuteReader
If dtrCentre.Read() Then
            lblName.Text = dtrCentre("mailname")
            lblAddress1.Text = dtrCentre("add_1")
            lblAddress2.Text = dtrCentre("add_2")
            lblAddress3.Text = dtrCentre("add_3")
            lblAddress4.Text = dtrCentre("add_4")
            lblPostcode.Text = dtrCentre("postcode")
End if
cnConnection.Close()

The HTML for these is then as follows:

<P>
<asp:Label id="lblAddress1" runat="server">Label</asp:Label><BR>
<asp:Label id="lblAddress2" runat="server">Label</asp:Label><BR>
<asp:Label id="lblAddress3" runat="server">Label</asp:Label><BR>
<asp:Label id="lblAddress4" runat="server">Label</asp:Label><BR>
<asp:Label id="lblPostcode" runat="server">Label</asp:Label>
</P>

What then happens is if all the labels aren't filled the linebreaks obviously still appear meaning I get the gaps as mentioned above.

What I need is a way to feed the 5 values into one object so that it doesn't matter if they don't appear

 
Old January 7th, 2005, 11:04 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

What about a single label and few tests?

AddLine(dtrCentre("mailname"))
AddLine(dtrCentre("add_1"))
AddLine(dtrCentre("add_2"))
AddLine(dtrCentre("add_3"))
AddLine(dtrCentre("add_4"))
AddLine(dtrCentre("postcode"))


Sub AddLine(strText As String)
    If strText.Length > 0 Then
        lblAddress.Text &= String.Format("{0}<br>", strText)
    End If
End Sub
 
Old January 11th, 2005, 10:36 AM
Registered User
 
Join Date: Jan 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thats it - this method occurred to me after I posted this but I couldn't work out how to do it!

Thanks so much for your help. I really appreciate it





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to display data in MSHFlexgrid Swati Chari VB How-To 3 July 22nd, 2008 10:15 AM
Display data within data range? ktsis ASP.NET 1.0 and 1.1 Basics 2 June 9th, 2006 03:06 PM
Display Data. mistry_bhavin ADO.NET 2 May 4th, 2004 09:22 AM
Datalist does not display data sanjeet ADO.NET 1 August 8th, 2003 11:26 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.