 |
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 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
|
|
|
|
|

October 18th, 2010, 01:52 PM
|
|
Registered User
|
|
Join Date: Oct 2010
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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>
|
|

October 18th, 2010, 07:15 PM
|
|
Registered User
|
|
Join Date: Oct 2010
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|

October 19th, 2010, 04:10 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|

October 20th, 2010, 02:10 PM
|
|
Registered User
|
|
Join Date: Oct 2010
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|

May 14th, 2011, 08:50 PM
|
|
Registered User
|
|
Join Date: May 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|

May 15th, 2011, 04:55 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|

May 15th, 2011, 02:38 PM
|
|
Registered User
|
|
Join Date: May 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|

May 15th, 2011, 03:03 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|

May 18th, 2011, 03:58 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|
 |