Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 18th, 2010, 01:52 PM
Registered User
 
Join Date: Oct 2010
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 12, page 406

I am beginning to think something is wrong with my system. This makes no sense and neither did the last ommitted code. Since I already have made the Authorized field a Template, I can no longer repeat that step, yet the appropriate Template code is not added to my copy of Reviews.aspx, so the action dictated in Step 9 has no code in my file to support that change. I have double checked my work and don't think I missed anything.

Tool:
Microsoft Visual Studio 2008
Version 9.0.30729.4462 QFE
Microsoft .NET Framework
Version 3.5 SP1
Installed Edition: Professional

My Code through step 8 on page 406:
Code:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="Id" DataSourceID="SqlDataSource2">
            <Columns>
                <asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="False" ReadOnly="True" SortExpression="Id" />
                <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
                <asp:CheckBoxField DataField="Authorized" HeaderText="Authorized" SortExpression="Authorized" />
                <asp:BoundField DataField="CreateDateTime" HeaderText="CreateDateTime" 
                    SortExpression="CreateDateTime" />
            </Columns>
        </asp:GridView>
Your source code from download:

Code:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource2">
				<Columns>
					<asp:HyperLinkField DataNavigateUrlFields="Id" DataNavigateUrlFormatString="AddEditReview.aspx?Id={0}" DataTextField="Title" HeaderText="Title" />
					<asp:TemplateField HeaderText="Authorized" SortExpression="Authorized">
						<ItemTemplate>
							<asp:Label ID="lblAuthorized" runat="server" Text='<%# GetBooleanText(Eval("Authorized")) %>' />
						</ItemTemplate>
					</asp:TemplateField>
					<asp:BoundField DataField="CreateDateTime" DataFormatString="{0:g}" HeaderText="CreateDateTime" SortExpression="CreateDateTime" />
					<asp:CommandField HeaderText="Delete" ShowDeleteButton="True" />
				</Columns>
			</asp:GridView>
Reply With Quote
  #2 (permalink)  
Old October 18th, 2010, 07:15 PM
Registered User
 
Join Date: Oct 2010
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Time to load the code from chapter 11 and start over.

Am I the only person who wonders where the label control in step 10 comes from? I figured it out and that is one very good lesson on ItemTemplate found in Help. However, the result of adding the EditTemplate and adding the label resulted in all the reviews being listed and that is not the desired outcome.
Reply With Quote
  #3 (permalink)  
Old October 19th, 2010, 04:10 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Quote:
Am I the only person who wonders where the label control in step 10 comes from?
The (invisible) default for a BoundField is to render its contents as a Label. As soon as you expand a BoundField to a TemplateField, VWD copies the (internal) controls to the template for you to change or remove completely.

I've seen cases where VWD does not always add the correct code to the control when you start customizing it. I've reported a few bugs at Microsoft on this and some of them were fixed. Looks like you are still running into one of them.

If VWD doesn't add the correct code for you, you can still enter it manually.....


Quote:
However, the result of adding the EditTemplate and adding the label resulted in all the reviews being listed and that is not the desired outcome.
Not sure I understand what you're saying here. Changing the templates shouldn't influence the number of reviews being displayed.

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!
Reply With Quote
  #4 (permalink)  
Old October 20th, 2010, 02:10 PM
Registered User
 
Join Date: Oct 2010
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The third time through was the charm for whatever reason.

Along the way a bit of learning happened in digging through the help files which is never a bad thing.
Reply With Quote
  #5 (permalink)  
Old May 14th, 2011, 08:50 PM
Registered User
Points: 6, Level: 1
Points: 6, Level: 1 Points: 6, Level: 1 Points: 6, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Smile Chapter 12 Exersize on pgs 404 - 407 for VWD 2008

Re: Chapter 12 Exersize on pgs 404 - 407

I think there may be two missing steps in the exercise.

Before step 8 I think we need to select the Auto-generate fields box on the left hand side and bottom of the Fields dialogue box.

Before step 12 I think we need to select the GridView control while in design view and then change AutoGenerateColumns in the properties window to false.

If I do that it seems to produce the result in figure 12-14.
Reply With Quote
  #6 (permalink)  
Old May 15th, 2011, 04:55 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi there,

Not sure why you would need that. I just tried th exercise (started with the preceding exercise at page 400), and it works exactly as described in the book.

What did that checkbox change for you? E.g. did you get additional columns in the markup? I've seen a number of reports similar to your where people don't get the request columns in the GridView to beging with (which seems to be a bug in Visual Studio). However, in this case, you manually delete all exsiting columns / fields,a nd then add them again using the Fields dialog....

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!
Reply With Quote
  #7 (permalink)  
Old May 15th, 2011, 02:38 PM
Registered User
Points: 6, Level: 1
Points: 6, Level: 1 Points: 6, Level: 1 Points: 6, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Smile

If I don't do the added steps I can not do step 9 and remove the code <EditItemTemplate> as it does not exist. Also if I leave autogenerate columns to true each column is repeated twice. There is nothing to delete if I do the steps other than what is in step 9.

Given you have different results, don't know if this is a bug, a configuration issue, a feature change between builds, or what.

By the way, I've learned a lot from your book and appreciate your efforts.

If you like I could send you my code of what it looks like at step 8 without my extra steps if you would like to see the result I'm getting which will show you why I needed to do the extra steps.

Last edited by mgerber2@comcast.net; May 15th, 2011 at 02:42 PM..
Reply With Quote
  #8 (permalink)  
Old May 15th, 2011, 03:03 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

I think it's a bug, as I've seen it work many times, but I've also seen reports of people who can't make it work.

Feel free to send me your source, and I'll take a look. You can e-mail me at firstname @ lastname dot com.

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!
Reply With Quote
  #9 (permalink)  
Old May 18th, 2011, 03:58 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi there,

I just followed the exercises from the start of the chapter with Reviews.aspx and again, it works as described in the book.

I can see from your page - ReviewsStep8.aspx - that things didn't end up as they should, which confirms this might be a bug.

I tried to make it work by following your steps, but couldn't. You said ReviewsStep8.aspx was the result of doing the exercise up and including step 8, right? But I don't see any of the changes made in the preceding steps, such as the custom format for some columns and the template. Or is that exactly what the issue is about? When I enable the checkbox in the Fields dialog, nothing happens, other than that the AutoGenerateColumns attribute is removed.

A persistent little bug(ger), this one.... ;-)

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!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 12 Page 410 Try it out JohnKiller BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 4 August 10th, 2010 02:49 PM
Chapter 1, page 11/12 jonzi_456 BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143 7 April 21st, 2010 09:18 PM
Chapter 12 - Page 406 - Step 9 - Not showing up this way? jn148 BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 7 December 14th, 2008 12:58 PM
Chapter 12: Page 410 - Try it out VeganMan BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 April 20th, 2008 03:44 PM
Minor textual error chapter 12 bottom of page 406 haguna BOOK: Professional VB 2005 ISBN: 0-7645-7536-8 0 April 16th, 2006 05:48 PM



All times are GMT -4. The time now is 02:06 PM.


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