Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | 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 April 4th, 2009, 02:35 PM
Authorized User
 
Join Date: Mar 2009
Posts: 64
Thanks: 0
Thanked 1 Time in 1 Post
Default DetailsView, p. 393

Imar,

In the "Try It Out" on p. 393 the code in the gray box does not look like mine and the display in Fig. 12-6 is slightly different.

My code resulting from the drag-and-drop and parameter setting is:

Code:
<asp:DetailsView ID="DetailsView1" runat="server" DataSourceID="SqlDataSource1" 
        DefaultMode="Insert" Height="50px" Width="125px">
        <Fields>
            <asp:CommandField ShowInsertButton="True" />
        </Fields>
    </asp:DetailsView>
with not nearly as much information as you show to expect.

In step 6 my display has the "Id" field in the DetailsView, yours does not.

Everything seems to work as you describe, it just looks different. Is that at all significant?

= = =

BTW, I have switched away from the "Web Application Project" in favor of the Web Site since there was enough different that it was distracting me from some of your intentions. I did this by picking up the book code at the end of a chapter, and continuing with it into the next chapter.

Thomas
Reply With Quote
  #2 (permalink)  
Old April 5th, 2009, 04:36 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: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi Thomas,

That's quite strange. I just went through the steps creating the Genre.aspx page (starting at page 387) and it works fine for me. I do get the necesary BoundField elements.

Is your database in order? Is Id the primary key column in the databaase? And did the previous exercise with the GridView work as described?

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
  #3 (permalink)  
Old April 5th, 2009, 08:55 AM
Authorized User
 
Join Date: Mar 2009
Posts: 64
Thanks: 0
Thanked 1 Time in 1 Post
Default

Imar,

I double checked the database. The "Id" field is the primary key in both the "Genre" and "Review" tables.

The previous exercise did work as described.

In my version of "Genres.aspx" the declaration for the asp:GridView does have 'DataKeyNames="Id"' in it.

I briefly looked for whatever settings there may be to change, but really had no idea what may have made our two displays different. Did anyone else mention anything like this?

Everything seems to work with the slight difference in the initial browser display.

I am using VS2008 Professional. I have included all the code below for my current version of "Genres.aspx". I have finished the exercises through and including the one that begins on p. 400, "Applying the Filter". I am curious about this and will investigate any leads you provide.

Thanks.

Thomas

Code:
<%@ Page Language="C#" MasterPageFile="~/MasterPages/ManagementMaster.master" AutoEventWireup="true"
    CodeFile="Genres.aspx.cs" Inherits="Management_Genres" Title="Planet Wrox - Management - Genres" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
                AutoGenerateColumns="False" DataKeyNames="Id" DataSourceID="SqlDataSource1" EmptyDataText="There are no data records to display.">
                <Columns>
                    <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowSelectButton="True" />
                    <asp:BoundField DataField="Id" HeaderText="Id" ReadOnly="True" SortExpression="Id" />
                    <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                    <asp:BoundField DataField="SortOrder" HeaderText="SortOrder" SortExpression="SortOrder" />
                </Columns>
            </asp:GridView>
            <asp:DetailsView ID="DetailsView1" runat="server" DataSourceID="SqlDataSource1" DefaultMode="Insert"
                Height="50px" Width="125px">
                <Fields>
                    <asp:CommandField ShowInsertButton="True" />
                </Fields>
            </asp:DetailsView>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:PlanetWroxConnectionString1 %>"
                DeleteCommand="DELETE FROM [Genre] WHERE [Id] = @Id" InsertCommand="INSERT INTO [Genre] ([Name], [SortOrder]) VALUES (@Name, @SortOrder)"
                ProviderName="<%$ ConnectionStrings:PlanetWroxConnectionString1.ProviderName %>"
                SelectCommand="SELECT [Id], [Name], [SortOrder] FROM [Genre]" UpdateCommand="UPDATE [Genre] SET [Name] = @Name, [SortOrder] = @SortOrder WHERE [Id] = @Id">
                <DeleteParameters>
                    <asp:Parameter Name="Id" Type="Int32" />
                </DeleteParameters>
                <InsertParameters>
                    <asp:Parameter Name="Name" Type="String" />
                    <asp:Parameter Name="SortOrder" Type="Int32" />
                </InsertParameters>
                <UpdateParameters>
                    <asp:Parameter Name="Name" Type="String" />
                    <asp:Parameter Name="SortOrder" Type="Int32" />
                    <asp:Parameter Name="Id" Type="Int32" />
                </UpdateParameters>
            </asp:SqlDataSource>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
Reply With Quote
  #4 (permalink)  
Old April 5th, 2009, 09:26 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: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

The code looks fine except for the missing fields in the DetailsView.

Can you send me a zipped verison of the site?

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
  #5 (permalink)  
Old April 5th, 2009, 10:28 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: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi Thomas,

I got the zip, and saw the same behavior. Not exactly sure what the issue is, but here's how to work around it:

1. Open the SqlDataSource's Smart Tasks panel and choose Configure Data Source

2. Click Next, Next and Finish to go through the Wizard. Don't change anything.

3. Voila. Instant fields in the DetailsView.

Not sure why they don't appear right away. I don't see any differences in the old and new source (other than the new Fields).

Did you create the entire page from scratch or did you base it on an existing one? I don't get the problem if I follow these steps:

1. Create a brand new page

2. Drag the Genre table on that page

3. Check all options for the GridView

4. Drag a DetailsView and hook it up to the SqlDataSource control.


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
  #6 (permalink)  
Old April 5th, 2009, 05:45 PM
Authorized User
 
Join Date: Mar 2009
Posts: 64
Thanks: 0
Thanked 1 Time in 1 Post
Default

Imar,

Curiouser and Curiouser.

I followed your first three steps:

Quote:
1. Open the SqlDataSource's Smart Tasks panel and choose Configure Data Source

2. Click Next, Next and Finish to go through the Wizard. Don't change anything.

3. Voila. Instant fields in the DetailsView.
and got the fields in the DetailsView. However, I had to go back to the SqlDataSource and Enable Inserting.

Even still, it is now missing the CommandField ShowInsertButton. When I display it in the browser there is no insert button. Here is the code.

Code:
            <asp:DetailsView ID="DetailsView1" runat="server" DataSourceID="SqlDataSource1" DefaultMode="Insert"
                Height="50px" Width="125px" AutoGenerateRows="False" DataKeyNames="Id">
                <Fields>
                    <asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="False" 
                        ReadOnly="True" SortExpression="Id" />
                    <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                    <asp:BoundField DataField="SortOrder" HeaderText="SortOrder" 
                        SortExpression="SortOrder" />
                </Fields>
            </asp:DetailsView>
I added that in the markup.

Code:
            <asp:DetailsView ID="DetailsView1" runat="server" DataSourceID="SqlDataSource1" DefaultMode="Insert"
                Height="50px" Width="125px" AutoGenerateRows="False" DataKeyNames="Id">
                <Fields>
                    <asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="False" ReadOnly="True"
                        SortExpression="Id" />
                    <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                    <asp:BoundField DataField="SortOrder" HeaderText="SortOrder" SortExpression="SortOrder" />
                    <asp:CommandField ShowInsertButton="true" />
                </Fields>
            </asp:DetailsView>
And then it appears as it does on the book, Fig. 12-6, p. 394.

I did create a brand new page as I was following the book literally. Your last 4 steps are those of the book.

Is there a setting in VS2008 someplace that may be affecting this?

Thomas
Reply With Quote
  #7 (permalink)  
Old April 5th, 2009, 05:54 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: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

It probably didn't pick it up because Inserting wasn't enabled on the SDS?

AFAIK, there's no "Act randomly strange" setting in VWD...

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
  #8 (permalink)  
Old May 15th, 2009, 11:12 AM
Registered User
 
Join Date: May 2009
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Same exact issue!

Just FYI, I am having the same exact issue as the original poster. I most definitely did NOT follow the book to the letter but I did basically the exact same thing -- and like the first guy I get no Bound Fields.

I ran the wizard as you suggested, it made no difference. I also mucked with everything I could in the Smart Tasks panel to see if anything would change. No joy.

I am using all the latest EXPRESS versions on Windows 7 RC build 7100.

My take: VWD = awesome, till it isn't, then it suxx.

Maybe a bug to report to Microsoft? You know anyone there??



Code:
<asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" 
        DataSourceID="SqlDataSource1" DefaultMode="Insert" Height="50px" Width="125px">
        <Fields>
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" 
                ShowInsertButton="True" />
        </Fields>
    </asp:DetailsView>
Reply With Quote
  #9 (permalink)  
Old May 15th, 2009, 11:49 AM
Registered User
 
Join Date: May 2009
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy Finally got it

I finally got it to work, just by mucking around with the SqlDataSource. I tossed the table onto the page again, which created another SqlDataSource (which I pointed to), and I opened the Smart Tasks panel for that and mucked around with specifying column names vs * vs custom SQL statement, etc and kept going back and forth to check on DetailsView to see if the BoundField's showed up -- until eventually they did. Pretty ugly, but it 'worked'.

Code:
    <asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" 
        DataSourceID="SqlDataSource3" DefaultMode="Insert" Height="50px" Width="323px" 
        AutoGenerateRows="False" DataKeyNames="Genre_ID">
        <FooterTemplate>
            footerrrrrrrr
        </FooterTemplate>
        <Fields>
            <asp:BoundField DataField="Genre_ID" HeaderText="Genre_ID" 
                InsertVisible="False" ReadOnly="True" SortExpression="Genre_ID" />
            <asp:BoundField DataField="Genre_Name" HeaderText="Genre_Name" 
                SortExpression="Genre_Name" />
            <asp:BoundField DataField="Genre_SortOrder" HeaderText="Genre_SortOrder" 
                SortExpression="Genre_SortOrder" />
        </Fields>
        <HeaderTemplate>
            headddd
        </HeaderTemplate>
    </asp:DetailsView>
Reply With Quote
  #10 (permalink)  
Old May 15th, 2009, 12:29 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: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Ugly indeed. Sounds like a bug to me.

I am not sure if the following site is "on invation only" but you could try here: https://connect.microsoft.com/default.aspx

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
Dropdownlists in DetailsView irelandk BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 February 20th, 2007 10:13 AM
DetailsView faithfulman ASP.NET 2.0 Basics 1 September 22nd, 2006 11:16 PM
detailsview pau5160 ASP.NET 2.0 Basics 0 August 21st, 2006 10:47 PM
dropdownlist value into detailsview: how? hertendreef ASP.NET 2.0 Professional 0 June 26th, 2006 01:54 AM



All times are GMT -4. The time now is 07:42 PM.


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