Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > ASP.NET 4 General Discussion
|
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion 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 July 2nd, 2012, 03:38 PM
Registered User
 
Join Date: May 2012
Posts: 6
Thanks: 2
Thanked 0 Times in 0 Posts
Default Listview...editing/updating/inserting layout

Hello

After going through the Wrox beginning ASP.NET 4 (+ 1 other) I'm having a play setting up my first ever website.

Part of that involves an admin page, allowing me to edit/insert/delete "news" entries with a headline, summary, date etc.

I've used a listview for this, and I've got it displaying the entries I put on the database manually, but I'm having problems getting it to display in a way that doesn't look a right mess.

http://img.photobucket.com/albums/v6...969/zmrfc1.png

Is there a way of maybe getting the text left aligned, and the boxes right aligned, rather than just having them next to each other?

Thanks, Richard.


ps as a website newbie, does the sense of tearing you hair out in frustration at controls not having parameters you think they ought to have, pass as you learn more about the subject, or does it get worse?
 
Old July 3rd, 2012, 02:45 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Richard,

You certainly can. The good thing about the ListView is that it's fully template driven, so you can control how it looks. Take a look at the InsertItemTemplate for example. You'll probably see something like this:

Code:
 
Date:
<asp:TextBox ID="DateTextBox" runat="server" Text='<%# Bind("Date") %>' /> <br />
HeadLine:
<asp:TextBox ID="HeadLineTextBox" runat="server" Text='<%# Bind("HeadLine") %>' /> <br />
As you can see this is plain HTML mixed with server controls so you can easily change how this looks by modifying the template code. For example you could wrap the controls in a table:

Code:
 
<table>
<tr>
  <td>Date:</td>
  <td><asp:TextBox ID="DateTextBox" runat="server" Text='<%# Bind("Date") %>' /> </td>
</tr>
<tr>
  <td>HeadLine:</td>
  <td><asp:TextBox ID="HeadLineTextBox" runat="server" Text='<%# Bind("HeadLine") %>' /><td>
</tr>
</table>
You could experiment a bit with the available layouts (explained on page 507) and see which one works best as a starting point.

Quote:
does the sense of tearing you hair out in frustration at controls not having parameters you think they ought to have, pass as you learn more about the subject, or does it get worse?
I'd say: it gets better ;-) Until then, be sure to ask for help on this forum before you get bald completely....;-)

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
RichardL1969 (July 3rd, 2012)
 
Old July 3rd, 2012, 06:16 AM
Registered User
 
Join Date: May 2012
Posts: 6
Thanks: 2
Thanked 0 Times in 0 Posts
Default

Thanks. It seems so obvious now.

I'd looked at arranging it using a table but couldn't see how I could make it work. All previous work with tables was mainly done with dragging and dropping from the toolbox into the table in design view, and obviously that can't be done with a whole ListView control.

Daft as it sounds now, I just hadn't made the mental step of "retro fitting" the table into the existing templates.

It still seems a little barmy to me that you can't format the layout of the listview using its own parameters, but that's probably me being picky/lazy. To people who know HTML like the back of their hand it probably would seem unecessary.
 
Old July 3rd, 2012, 07:13 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Yeah, I agree. However, considering the flexibility you have in designing the templates, I think it would be pretty difficult to provide design time capabilities for that.

I think you could move the code for, say, the InsertItemTemplate to another page, do your design work there, and then copy it back into the ListView when you're done. Not ideal, but it might help.

Quote:
To people who know HTML like the back of their hand it probably would seem unecessary.
Maybe. altough a quick preview would still help for them as well.

So, better start knowing HTML like the back of your hand then.... ;-)

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
GridView w/ StoredProc: Editing/Updating Values (C#) wcdsb-dahi ASP.NET 3.5 Professionals 1 November 5th, 2012 05:50 AM
Double Inserting in Listview after Refresh by user hans ASP.NET 3.5 Basics 3 June 9th, 2009 11:02 AM
editing and updating a gridview sarah lee ASP.NET 2.0 Basics 2 December 22nd, 2006 05:45 AM
Editing Updating Sorting an Unbound Gridview Robby ASP.NET 2.0 Professional 5 March 22nd, 2006 10:41 AM
Visual Basic code for Updating (Editing) DataSet11 connijean VB Databases Basics 0 May 5th, 2004 05:53 PM





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