Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > BOOK: Beginning ASP.NET 4 : in C# and VB
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB 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 November 26th, 2011, 02:45 PM
Authorized User
Points: 285, Level: 5
Points: 285, Level: 5 Points: 285, Level: 5 Points: 285, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2010
Posts: 71
Thanks: 12
Thanked 0 Times in 0 Posts
Default Detailsview not working...

Hi all

I have a default page with a gridview on with lots of data. You can click one of the clients names and it links to another page showing a details view. This all works fine.

I then added another details view below that second page to display another tables data that corresponds to the client name in question. But for some reaosn this second details view will not show anything at all...

Here is my code for the second page. Any thoughts?


Code:
<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="AddEditNames.aspx.vb" Inherits="ManagementTest_AddEditNames" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
    <p><a href="IssueSearch.aspx">Back to Client Condition selection</a></p>
    <p><a href="NamesSearch.aspx">Back to Client Name selection</a></p>
    <h1>Client details</h1>
        <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" 
            DataKeyNames="ID" DataSourceID="SqlDataSource1" DefaultMode="Insert">
            <Fields>
                <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" 
                    ReadOnly="True" SortExpression="ID" />
                <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                <asp:BoundField DataField="Surname" HeaderText="Surname" 
                    SortExpression="Surname" />
                <asp:BoundField DataField="Age" HeaderText="Age" SortExpression="Age" />
                <asp:BoundField DataField="IssueID" HeaderText="IssueID" 
                    SortExpression="IssueID" />
                <asp:BoundField DataField="Address01" HeaderText="Address01" 
                    SortExpression="Address01" />
                <asp:BoundField DataField="Address02" HeaderText="Address02" 
                    SortExpression="Address02" />
                <asp:BoundField DataField="Address03" HeaderText="Address03" 
                    SortExpression="Address03" />
                <asp:BoundField DataField="PostCode" HeaderText="PostCode" 
                    SortExpression="PostCode" />
                <asp:BoundField DataField="Telephone" HeaderText="Telephone" 
                    SortExpression="Telephone" />
                <asp:BoundField DataField="Mobile" HeaderText="Mobile" 
                    SortExpression="Mobile" />
                <asp:TemplateField HeaderText="Email" SortExpression="Email">
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox2" TextMode="SingleLine" Width="100" runat="server" Text='<%# Bind("Email") %>'></asp:TextBox>
                    </EditItemTemplate>
                    <InsertItemTemplate>
                        <asp:TextBox ID="TextBox2" TextMode="SingleLine" runat="server" Text='<%# Bind("Email") %>'></asp:TextBox>
                    </InsertItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label2" runat="server" Text='<%# Bind("Email") %>'></asp:Label>
                    </ItemTemplate>
                    <ItemStyle Width="150px" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Notes" SortExpression="Notes">
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox1" TextMode="MultiLine" Width="500" Height="250" runat="server" Text='<%# Bind("Notes") %>'></asp:TextBox>
                    </EditItemTemplate>
                    <InsertItemTemplate>
                        <asp:TextBox ID="TextBox1" TextMode="MultiLine" Width="500" Height="250" runat="server" Text='<%# Bind("Notes") %>'></asp:TextBox>
                    </InsertItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("Notes") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:CheckBoxField DataField="Active" HeaderText="Active" 
                    SortExpression="Active" />
                <asp:BoundField DataField="DateCreated" HeaderText="DateCreated" 
                    SortExpression="DateCreated" DataFormatString="{0:g}" />
                <asp:CommandField ShowEditButton="True" ShowInsertButton="True" />
            </Fields>
        </asp:DetailsView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            DeleteCommand="DELETE FROM [names] WHERE [ID] = @ID" 
            InsertCommand="INSERT INTO [names] ([Name], [Surname], [Age], [IssueID], [Address01], [Address02], [Address03], [PostCode], [Telephone], [Mobile], [Email], [Notes], [Active], [DateCreated]) VALUES (@Name, @Surname, @Age, @IssueID, @Address01, @Address02, @Address03, @PostCode, @Telephone, @Mobile, @Email, @Notes, @Active, @DateCreated)" 
            SelectCommand="SELECT [ID], [Name], [Surname], [Age], [IssueID], [Address01], [Address02], [Address03], [PostCode], [Telephone], [Mobile], [Email], [Notes], [Active], [DateCreated] FROM [names] WHERE ([ID] = @ID)" 
            UpdateCommand="UPDATE [names] SET [Name] = @Name, [Surname] = @Surname, [Age] = @Age, [IssueID] = @IssueID, [Address01] = @Address01, [Address02] = @Address02, [Address03] = @Address03, [PostCode] = @PostCode, [Telephone] = @Telephone, [Mobile] = @Mobile, [Email] = @Email, [Notes] = @Notes, [Active] = @Active, [DateCreated] = @DateCreated WHERE [ID] = @ID">
            <DeleteParameters>
                <asp:Parameter Name="ID" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="Name" Type="String" />
                <asp:Parameter Name="Surname" Type="String" />
                <asp:Parameter Name="Age" Type="String" />
                <asp:Parameter Name="IssueID" Type="Int32" />
                <asp:Parameter Name="Address01" Type="String" />
                <asp:Parameter Name="Address02" Type="String" />
                <asp:Parameter Name="Address03" Type="String" />
                <asp:Parameter Name="PostCode" Type="String" />
                <asp:Parameter Name="Telephone" Type="Int32" />
                <asp:Parameter Name="Mobile" Type="String" />
                <asp:Parameter Name="Email" Type="String" />
                <asp:Parameter Name="Notes" Type="String" />
                <asp:Parameter Name="Active" Type="Boolean" />
                <asp:Parameter DbType="Date" Name="DateCreated" />
            </InsertParameters>
            <SelectParameters>
                <asp:QueryStringParameter Name="ID" QueryStringField="id" Type="Int32" />
            </SelectParameters>
            <UpdateParameters>
                <asp:Parameter Name="Name" Type="String" />
                <asp:Parameter Name="Surname" Type="String" />
                <asp:Parameter Name="Age" Type="String" />
                <asp:Parameter Name="IssueID" Type="Int32" />
                <asp:Parameter Name="Address01" Type="String" />
                <asp:Parameter Name="Address02" Type="String" />
                <asp:Parameter Name="Address03" Type="String" />
                <asp:Parameter Name="PostCode" Type="String" />
                <asp:Parameter Name="Telephone" Type="Int32" />
                <asp:Parameter Name="Mobile" Type="String" />
                <asp:Parameter Name="Email" Type="String" />
                <asp:Parameter Name="Notes" Type="String" />
                <asp:Parameter Name="Active" Type="Boolean" />
                <asp:Parameter DbType="Date" Name="DateCreated" />
                <asp:Parameter Name="ID" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
   
    <h1>
        Pre-Therapy contact
    </h1>
        <asp:DetailsView ID="DetailsView2" runat="server" AutoGenerateRows="False" 
            DataKeyNames="ID" DataSourceID="SqlDataSource2" DefaultMode="Insert">
            <Fields>
                <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" 
                    ReadOnly="True" SortExpression="ID" />
                <asp:BoundField DataField="FirstContactDate" HeaderText="FirstContactDate" 
                    SortExpression="FirstContactDate" />
                <asp:BoundField DataField="FindYouList" 
                    HeaderText="FindYouList" SortExpression="FindYouList" />
                <asp:BoundField DataField="FingYou" HeaderText="FingYou" 
                    SortExpression="FingYou" />
                <asp:BoundField DataField="InitialContact" HeaderText="InitialContact" 
                    SortExpression="InitialContact" />
                <asp:BoundField DataField="Impressions" HeaderText="Impressions" 
                    SortExpression="Impressions" />
                <asp:BoundField DataField="Feel" HeaderText="Feel" SortExpression="Feel" />
                <asp:BoundField DataField="DescribedIssue" HeaderText="DescribedIssue" 
                    SortExpression="DescribedIssue" />
                <asp:BoundField DataField="WorkiningWithClient" 
                    HeaderText="WorkiningWithClient" SortExpression="WorkiningWithClient" />
                <asp:CheckBoxField DataField="PreviousTherapy" HeaderText="PreviousTherapy" 
                    SortExpression="PreviousTherapy" />
                <asp:BoundField DataField="PreviousID" 
                    HeaderText="PreviousID" 
                    SortExpression="PreviousID" />
                <asp:BoundField DataField="UpdatedDate" HeaderText="UpdatedDate" 
                    SortExpression="UpdatedDate" />
                <asp:BoundField DataField="ClientId" HeaderText="ClientId" 
                    SortExpression="ClientId" />
                <asp:CommandField ShowEditButton="True" ShowInsertButton="True" />
            </Fields>
        </asp:DetailsView>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            DeleteCommand="DELETE FROM [PreTherapy] WHERE [ID] = @ID" 
            InsertCommand="INSERT INTO [PreTherapy] ([FirstContactDate], [FindYouList], [FingYou], [InitialContact], [Impressions], [Feel], [DescribedIssue], [WorkiningWithClient], [PreviousTherapy], [PreviousID], [UpdatedDate], [ClientId]) VALUES (@FirstContactDate, @FindYouList, @FingYou, @InitialContact, @Impressions, @Feel, @DescribedIssue, @WorkiningWithClient, @PreviousTherapy, @PreviousID, @UpdatedDate, @ClientId)" 
            SelectCommand="SELECT ID, FirstContactDate, FindYouList, FingYou, InitialContact, Impressions, Feel, DescribedIssue, WorkiningWithClient, PreviousTherapy, PreviousID, UpdatedDate, ClientId FROM PreTherapy WHERE (ID = @ID)" 
            
        UpdateCommand="UPDATE [PreTherapy] SET [FirstContactDate] = @FirstContactDate, [FindYouList] = @FindYouList, [FingYou] = @FingYou, [InitialContact] = @InitialContact, [Impressions] = @Impressions, [Feel] = @Feel, [DescribedIssue] = @DescribedIssue, [WorkiningWithClient] = @WorkiningWithClient, [PreviousTherapy] = @PreviousTherapy, [PreviousID] = @PreviousID, [UpdatedDate] = @UpdatedDate, [ClientId] = @ClientId WHERE [ID] = @ID">
            <DeleteParameters>
                <asp:Parameter Name="ID" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="FirstContactDate" Type="DateTime" />
                <asp:Parameter Name="FindYouList" Type="Int32" />
                <asp:Parameter Name="FingYou" Type="String" />
                <asp:Parameter Name="InitialContact" Type="String" />
                <asp:Parameter Name="Impressions" Type="String" />
                <asp:Parameter Name="Feel" Type="String" />
                <asp:Parameter Name="DescribedIssue" Type="String" />
                <asp:Parameter Name="WorkiningWithClient" Type="String" />
                <asp:Parameter Name="PreviousTherapy" Type="Boolean" />
                <asp:Parameter Name="PreviousID" Type="Int32" />
                <asp:Parameter Name="UpdatedDate" Type="DateTime" />
                <asp:Parameter Name="ClientId" Type="Int32" />
            </InsertParameters>
            <SelectParameters>
                <asp:QueryStringParameter Name="ID" QueryStringField="ID" Type="Int32" />
            </SelectParameters>
            <UpdateParameters>
                <asp:Parameter Name="FirstContactDate" Type="DateTime" />
                <asp:Parameter Name="FindYouList" Type="Int32" />
                <asp:Parameter Name="FingYou" Type="String" />
                <asp:Parameter Name="InitialContact" Type="String" />
                <asp:Parameter Name="Impressions" Type="String" />
                <asp:Parameter Name="Feel" Type="String" />
                <asp:Parameter Name="DescribedIssue" Type="String" />
                <asp:Parameter Name="WorkiningWithClient" Type="String" />
                <asp:Parameter Name="PreviousTherapy" Type="Boolean" />
                <asp:Parameter Name="PreviousID" Type="Int32" />
                <asp:Parameter Name="UpdatedDate" Type="DateTime" />
                <asp:Parameter Name="ClientId" Type="Int32" />
                <asp:Parameter Name="ID" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
    </p>
</asp:Content>
Reply With Quote
  #2 (permalink)  
Old November 26th, 2011, 06:52 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

Your second SqlDataSource seems to be set up to use the same ID query string parameter and then uses it to query a different table. Do both tables have identical and matching IDs? Or did you intend to query on a different column?

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 November 27th, 2011, 01:46 PM
Authorized User
Points: 285, Level: 5
Points: 285, Level: 5 Points: 285, Level: 5 Points: 285, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2010
Posts: 71
Thanks: 12
Thanked 0 Times in 0 Posts
Default

My tables have the same ID to identify a client so need to use the same ID so that the second table brings up data relevant to that client. Is that right then? Why do you think it is wrong?
Reply With Quote
  #4 (permalink)  
Old November 27th, 2011, 02:21 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 am not saying it's wrong, I am only guessing. Two tables having a primary key that are supposed to be in sync is generally asking for trouble though. What happens when you delete a record in one, but not in the other?

What I thought you were doing is querying two separate tables for the same ID. E.g.:

WHERE ID = Request.QueryStyring.Get("ID")

Are you sure both tables should returm a record for the ID you're passing into the query string?

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
The Following User Says Thank You to Imar For This Useful Post:
leeWozyWarren (November 28th, 2011)
  #5 (permalink)  
Old November 28th, 2011, 08:08 AM
Authorized User
Points: 285, Level: 5
Points: 285, Level: 5 Points: 285, Level: 5 Points: 285, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2010
Posts: 71
Thanks: 12
Thanked 0 Times in 0 Posts
Default

Let me have a look at this and come back to you. Thanks.
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
Cascading dropdownlists not working in the edit template of detailsview thd_tq123 ASP.NET 3.5 Professionals 1 February 27th, 2009 07:55 AM
DetailsView update not working. Andrew.Berry ASP.NET 2.0 Professional 6 April 22nd, 2008 11:23 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



All times are GMT -4. The time now is 08:04 AM.


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