Data Binding in ASP.Net 2.0
 
Repeater Web Server Control
 
The Repeater Web server control is a like a container control that lets you to create custom lists out of any data that is available to the page. This control presents the items from a data source in a custom layout by repeating a specified template for each item in the list.
 
As Repeater control does not have a built-in rendering of its own, so you must provide the layout for the Repeater control by creating templates. We can also say that Repeater control does not have an inherent appearance. The Repeater control is different from other data list controls in that it allows you to place HTML fragments in its templates. This allows you to create a complex HTML structure, such as a table.If you want a different look for alternating items in the table, create an AlternatingItemTemplate with the same contents as the ItemTemplate, except with a different style specified. At last, complete the table by placing the </table> tag in the FooterTemplate.
 
The list the different templates of the Repeater control is given below.
 
Template Explanation
AlternatingItemTemplate Similar to the ItemTemplate element, but rendered for every other row (alternating items) in the Repeater control. You can specify a different representation looks for the AlternatingItemTemplate element by setting its style properties.
FooterTemplate This is used for the elements to render once, after all data-bound rows have been rendered. A typical use is to close an element opened in the HeaderTemplate item (with a tag such as </table>
HeaderTemplate This is used for the elements to render once, before any data-bound rows have been rendered. A typical use is to begin a container element, such as a table.
ItemTemplate This is used for the elements that are rendered once for each row in the data source. To display data in the ItemTemplate, declare one or more Web server controls and set their data-binding expressions to evaluate to a field in the Repeater control's (that is, the container control's) DataSource
SeparatorTemplate Elements to render between each row, typically line breaks (<br> tags), horizontal lines (<hr> tags), and so on.
 
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"/>