asp.net FormView example: how to use ItemTemplate and Paging
FormViewExample.aspx
- <%@ Page Language="C#" %>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <script runat="server">
- </script>
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head runat="server">
- <title>asp.net FormView example: how to use ItemTemplate and Paging</title>
- </head>
- <body>
- <form id="form1" runat="server">
- <div>
- <h2 style="color:Red">Example: FormView</h2>
- <asp:SqlDataSource
- ID="SqlDataSource1"
- runat="server"
- ConnectionString="<%$ ConnectionStrings:PubsConnectionString %>"
- SelectCommand="SELECT emp_id, fname, lname, hire_date FROM employee"
- >
- </asp:SqlDataSource>
- <asp:FormView
- ID="FormView1"
- runat="server"
- DataSourceID="SqlDataSource1"
- DataKeyNames="emp_id"
- AllowPaging="true"
- >
- <HeaderTemplate>
- Employee Details
- </HeaderTemplate>
- <HeaderStyle
- BackColor="DarkBlue"
- ForeColor="AliceBlue"
- BorderColor="DarkOrange"
- BorderStyle="None"
- BorderWidth="2"
- Font-Size="Medium"
- Font-Italic="false"
- Font-Bold="true"
- Height="35"
- HorizontalAlign="Center"
- />
- <ItemTemplate>
- <b>Employee ID:</b> <i><%# Eval("emp_id") %></i>
- <br />
- <b>Employee Name:</b> <i><%# Eval("lname") %> <%# Eval("fname") %></i>
- <br />
- <b>Hire Date:</b> <i><%# Eval("hire_date") %></i>
- </ItemTemplate>
- <RowStyle
- BackColor="DodgerBlue"
- ForeColor="AliceBlue"
- />
- <PagerSettings Mode="NumericFirstLast" FirstPageText="First" LastPageText="Last" />
- <PagerStyle BackColor="DarkBlue" ForeColor="AliceBlue" />
- </asp:FormView>
- </div>
- </form>
- </body>
- </html>
0 comments:
Post a Comment