System.Web.UI.WebControls Namespace Repeater Class
Binds a data source to a Repeater control.
[ VB ]
Overrides Public Sub DataBind ( )
[ C# ]
public override void DataBind ( );
[ C++ ]
public: void DataBind ( );
[ JScript ]
public override function DataBind ( );
Use the DataBind method to bind a DataSource to the Repeater control. Binding the data source with the control enables the information in the data source to be displayed in the Repeater.
The DataBind method is also commonly used to synchronize the data source and a Repeater after information in the data source is updated. This allows any changes in the data source to also be updated in the control.
The below snippet demonstrates how to dynamically bind a data source to a Repeater control when the page loads at run time. The data source in this case is an OleDbDataReader.
<script language = "C#" runat = "server">
void Page_Load ( Object src, EventArgs e ) {
// ... code to fetch data into a datareader here ...
// bind the repeater to the datareader
myRepeater.DataSource = myReader;
myRepeater.DataBind ( );
// close the connection
myConn.Close ( );
}
</script>
<asp:repeater id = "myRepeater" runat = "server">
...
</asp:repeater>
<script language = "VB" runat = "server">
sub Page_Load ( ByVal src as Object, ByVal e as EventArgs )
' ... code to fetch data into a datareader here ...
' bind the repeater to the datareader
myRepeater.DataSource = myReader
myRepeater.DataBind ( )
' close the connection
myConn.Close ( )
end sub
</script>
<asp:repeater id = "myRepeater" runat = "server">
...
</asp:repeater> |
|
C# |
VB |
Show me
Repeater Members