• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 504
  • Last Modified:

FormView control only displays one row of data

My FormView control only displays the first row returned by my sql query. What am i doing wrong?

<asp:SqlDataSource ID="sds1" runat="server" ConnectionString ="<%$ ConnectionStrings:conn %>"
        SelectCommand="SELECT title_id,title, type, price, notes, pubdate FROM titles ORDER BY title"
        UpdateCommand="UPDATE titles SET title = @title, type = @type, price=@price, notes=@notes, pubdate=@pubdate WHERE title_id = @title_id">
            <UpdateParameters>
        <asp:Parameter Type="String" Name="title"></asp:Parameter>
                  <asp:Parameter Type="String" Name="type"></asp:Parameter>
                <asp:Parameter Type="Decimal" Name="price"></asp:Parameter>
                  <asp:Parameter Type="String" Name="notes"></asp:Parameter>
                  <asp:Parameter Type="DateTime" Name="pubdate"></asp:Parameter>
                <asp:Parameter Type="String" Name="title_id"></asp:Parameter>
            </UpdateParameters>
</asp:SqlDataSource>
            <asp:SqlDataSource ID="sds2" runat="server" ConnectionString ="<%$ ConnectionStrings:conn %>" SelectCommand="SELECT DISTINCT type FROM titles"></asp:SqlDataSource>
            <asp:FormView ID="FormView1" runat="server" DataSourceID="sds1" DataKeyNames="title_id" CellPadding="4" DataMember="DefaultView" ForeColor="#333333">
            <ItemTemplate>
            <table>
            <tr>
            <td>
             <asp:Label ID="lblID" runat="server"
                          Text='<%#Eval("title_id") %>' Visible="false">
    </asp:Label>
    </td>
  <td>
    <asp:Label ID="lblTitle" runat="server"
               Text='<%#Eval("Title") %>'>
    </asp:Label>
   </td>
   <td>
                <asp:DropDownList ID="ddlType" DataSourceID="sds2" DataTextField="type" DataValueField="type"  SelectedValue='<%# Bind("type") %>' runat="server" Width="130px"></asp:DropDownList>
                </td>
                <td>
    <asp:Label ID="lblPrice" runat="server"
               Text='<%# Eval("price", "{0:c}")  %>'>
    </asp:Label>
    </td>
                <td>
    <asp:Label ID="lblNotes" runat="server"
               Text='<%#Eval("notes") %>'>
    </asp:Label>
    </td>
            </tr>
            </table>
            </ItemTemplate>
            <EditItemTemplate>
            <table>
            <tr>
              <td>
    <asp:TextBox ID="txtTitle" runat="server"
                 Text='<%#Bind("Title") %>'>
    </asp:TextBox>
   </td>
   <td>
                <asp:DropDownList ID="ddlType" DataSourceID="sds2" DataTextField="type" DataValueField="type"  SelectedValue='<%# Bind("type") %>' runat="server" Width="130px"></asp:DropDownList>
                </td>
   <td>
    <asp:TextBox ID="txtPrice" runat="server"
                 Text='<%#Bind("price") %>'>
    </asp:TextBox>
     </td>
   <td>
    <asp:TextBox ID="txtNotes" runat="server"
                 Text='<%#Bind("notes") %>' TextMode="MultiLine" Rows="3" Width="300">
    </asp:TextBox>
    </td>
   <td>
    <asp:TextBox ID="txtPubDate" runat="server"
                 Text='<%#Bind("pubdate") %>'>
    </asp:TextBox>
    </td>
            </tr>
            </table>
            </EditItemTemplate>
                <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
                <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
                <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
                <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
            </asp:FormView>
0
YZlat
Asked:
YZlat
1 Solution
 
Jens FiedererCommented:
You are doing nothing wrong....as the MSDN states (emphasis added):

"In the FormView control, a page of data is a SINGLE BOUND RECORD. If you set the AllowPaging property of the FormView control to true, the FormView control automatically adds user interface (UI) controls for paging. You can customize the UI for paging by adding a PagerTemplate template. For details, see Paging in a FormView Web Server Control."
0
 
guru_samiCommented:
As mentioned above FV will display one item at a time.
And if you want to display multiple rows you will have to use another controls like Repeater/DataList or ListView.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now