Data Binding in ASP.Net 2.0
 
FormView Web Server Control
 
The FormView control presents you the facility to work with a single record from a data source, similar to the DetailsView control. The dissimilarity between the FormView and the DetailsView controls is that the DetailsView control uses a tabular layout where each field of the record is displayed as a row of its own. In contrast, the FormView control does not specify a pre-defined layout for displaying the record. Instead, you create a template containing controls to display individual fields from the record. The template contains the formatting, controls, and binding expressions used to create the form.
 
Customizing User Interface of FormView Control
 
You can create the user interface for the FormView control by creating templates. You specify different templates for different actions. You create an ItemTemplate template for display, insert, and edit modes, as given in the example. You can customize the FormView control's header and footer using a HeaderTemplate and FooterTemplate, respectively.
 
Inserting, Updating and Deleting Data using DetailsView
 
The FormView supports automatic Updates, Inserts, and Deletes through its associated data source control just like the DetailsView control. The FormView control renders only a single data record at a time, even if its data source exposes multiple records.
 
The FormView control is able to automatically perform paging the data in its connected data source one record at a time, provided that the data is represented by an object implementing the ICollection interface, or that the underlying data source supports paging. The FormView control provides the user interface for navigating between records. To allow paging, set the AllowPaging property to true and specify a PagerTemplate value.
 
<asp:FormView ID="MyFormView"
DataSourceID="SqlDataSourceIDString"
AllowPaging="true" runat="server">
<HeaderStyle forecolor="white" backcolor="pink" />
<ItemTemplate>
<table>
<tr> <td align="right"><b>Product ID:</b></td>
<td><asp:Label id="Label_A" runat="server" Text=?LabelA? /></td>
</tr>
<tr> <td align="right"><b>Product Name:</b></td>
<td><asp:Label id="Label_B" runat="server" Text=?LabelB? /></td>
</tr>
</table>
</ItemTemplate>
<PagerTemplate>
<table>
<tr>
<td><asp:LinkButton ID="A_Button" CommandName="Page" CommandArgument=" Command_A" Text="Button_A" RunAt="server"/></td><br>
<td><asp:LinkButton ID="vButton" CommandName="Page" CommandArgument=" Command_B" Text=" Button_B" RunAt="server"/></td>
</tr>
</table>
</PagerTemplate>
</asp:FormView>
</td>
</tr>
</table>
<asp:SqlDataSource ID="ProductsSqlDataSource"
SelectCommand="Select query String"
connectionstring=?connection string?
RunAt="server"/>