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.
Any ideas? Thank you in advance.
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
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
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
CODE -->