×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Records won't display in DetailsView

Records won't display in DetailsView

Records won't display in DetailsView

(OP)
I currently have a table in DetailsView that has insert / edit capabilities, and is also filtered based on customer (constituent) ID. Currently, the table only appears in a browser if the constituent has a previous entry to filter by. I need this table to be viewable for all constituents, even if they do not have a previous entry so we can insert new entries for that constituent. Please find my code below.

CODE --> ASPX

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="697px" 
            AllowPaging="True" AutoGenerateRows="False" DataKeyNames="NamedSeatId" 
            DataSourceID="SqlDataSource1">
            <Fields>
                <asp:BoundField DataField="ConstituentId" HeaderText="ConstituentId" 
                    SortExpression="ConstituentId" />
                <asp:BoundField DataField="NamedSeatId" HeaderText="NamedSeatId" 
                    InsertVisible="False" ReadOnly="True" SortExpression="NamedSeatId" />
                <asp:BoundField DataField="HallId" HeaderText="HallId" 
                    SortExpression="HallId" />
                <asp:BoundField DataField="SectionId" HeaderText="SectionId" 
                    SortExpression="SectionId" />
                <asp:BoundField DataField="Seat" HeaderText="Seat" SortExpression="Seat" />
                <asp:BoundField DataField="GiftOf" HeaderText="GiftOf" 
                    SortExpression="GiftOf" />
                <asp:BoundField DataField="Honoree" HeaderText="Honoree" 
                    SortExpression="Honoree" />
                <asp:CommandField ButtonType="Button" ShowEditButton="True" 
                    ShowInsertButton="True" />
            </Fields>

        </asp:DetailsView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConflictDetection="CompareAllValues" 
            ConnectionString="<%$ ConnectionStrings:ImpresarioConnectionString-LIVE %>" 
            DeleteCommand="DELETE FROM [sl_NamedSeat] WHERE [NamedSeatId] = @original_NamedSeatId AND [HallId] = @original_HallId AND [SectionId] = @original_SectionId AND [Seat] = @original_Seat AND (([GiftOf] = @original_GiftOf) OR ([GiftOf] IS NULL AND @original_GiftOf IS NULL)) AND (([Honoree] = @original_Honoree) OR ([Honoree] IS NULL AND @original_Honoree IS NULL)) AND (([ConstituentId] = @original_ConstituentId) OR ([ConstituentId] IS NULL AND @original_ConstituentId IS NULL))" 
            InsertCommand="INSERT INTO [sl_NamedSeat] ([HallId], [SectionId], [Seat], [GiftOf], [Honoree], [ConstituentId]) VALUES (@HallId, @SectionId, @Seat, @GiftOf, @Honoree, @ConstituentId)" 
            OldValuesParameterFormatString="original_{0}" 
            SelectCommand="SELECT * FROM [sl_NamedSeat] Where ConstituentId = @ConstituentId" 
            UpdateCommand="UPDATE [sl_NamedSeat] SET [HallId] = @HallId, [SectionId] = @SectionId, [Seat] = @Seat, [GiftOf] = @GiftOf, [Honoree] = @Honoree, [ConstituentId] = @ConstituentId WHERE [NamedSeatId] = @original_NamedSeatId AND [HallId] = @original_HallId AND [SectionId] = @original_SectionId AND [Seat] = @original_Seat AND (([GiftOf] = @original_GiftOf) OR ([GiftOf] IS NULL AND @original_GiftOf IS NULL)) AND (([Honoree] = @original_Honoree) OR ([Honoree] IS NULL AND @original_Honoree IS NULL)) AND (([ConstituentId] = @original_ConstituentId) OR ([ConstituentId] IS NULL AND @original_ConstituentId IS NULL))">
            <SelectParameters>
                <asp:QueryStringParameter Name="ConstituentId" QueryStringField="ConstituentId" />
            </SelectParameters>
            <DeleteParameters>
                <asp:Parameter Name="original_NamedSeatId" Type="Int32" />
                <asp:Parameter Name="original_HallId" Type="Int32" />
                <asp:Parameter Name="original_SectionId" Type="Int32" />
                <asp:Parameter Name="original_Seat" Type="String" />
                <asp:Parameter Name="original_GiftOf" Type="String" />
                <asp:Parameter Name="original_Honoree" Type="String" />
                <asp:Parameter Name="original_ConstituentId" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="HallId" Type="Int32" />
                <asp:Parameter Name="SectionId" Type="Int32" />
                <asp:Parameter Name="Seat" Type="String" />
                <asp:Parameter Name="GiftOf" Type="String" />
                <asp:Parameter Name="Honoree" Type="String" />
                <asp:Parameter Name="ConstituentId" Type="Int32" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="HallId" Type="Int32" />
                <asp:Parameter Name="SectionId" Type="Int32" />
                <asp:Parameter Name="Seat" Type="String" />
                <asp:Parameter Name="GiftOf" Type="String" />
                <asp:Parameter Name="Honoree" Type="String" />
                <asp:Parameter Name="ConstituentId" Type="Int32" />
                <asp:Parameter Name="original_NamedSeatId" Type="Int32" />
                <asp:Parameter Name="original_HallId" Type="Int32" />
                <asp:Parameter Name="original_SectionId" Type="Int32" />
                <asp:Parameter Name="original_Seat" Type="String" />
                <asp:Parameter Name="original_GiftOf" Type="String" />
                <asp:Parameter Name="original_Honoree" Type="String" />
                <asp:Parameter Name="original_ConstituentId" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
    </div>
    </form>
</body>
</html> 

Any ideas? Thank you in advance.

RE: Records won't display in DetailsView

Can you return a 'default' instantiation of a constituent when there isn't an existing on in your data source?

You would probably need to customise the view to template fields so you can hide/show an edit button as appropriate tho' as you probably wouldn't want to allow editing of such.

Rhys

"Technological progress is like an axe in the hands of a pathological criminal"
"Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe"
Albert Einstein

RE: Records won't display in DetailsView

(OP)
Thank you for your response.

As of now, the screen appears blank and the details view is not visible if a constituent isnt existing in my data source.

I've never customized a view to template fields before...

RE: Records won't display in DetailsView

(OP)
Adding an EmptyTemplate did the trick.

CODE -->

<EmptyDataTemplate>
<div class="noMatch">
<h1>No Matching Results!</h1>
Please select a different record.
<asp:Button ID="InsertButton" runat="server" Text="Insert New record" CommandName="New" />
</div>
</EmptyDataTemplate> 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close