Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
VB.NET
C#
if(!Page.IsPostBack)
{
//Populate the Data in the Repeater
}
VB.NET
C#
VB.NET
Dim ds As DataSet
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ds = 'Assign proper value to dataset
Dim dc As DataColumn
Dim dr As DataRow
Dim rpthdr As New TemplateBuilder
Dim rptitem As New TemplateBuilder
Dim strval As String
For Each dc In ds.Tables(0).Columns
If strval = "" Then
strval = dc.ColumnName & " "
Else
strval = strval & dc.ColumnName & " "
End If
Next
rpthdr.AppendLiteralString(strval)
Repeater1.HeaderTemplate = rpthdr
Repeater1.DataSource = ds
Repeater1.DataBind()
End Sub
C#
DataSet ds;
private void Page_Load(object sender, System.EventArgs e)
{
ds = something;
DataColumn dc;
DataRow dr;
TemplateBuilder rpthdr = new TemplateBuilder();
TemplateBuilder rptitem = new TemplateBuilder();
string strval;
foreach (int dc in ds.Tables(0).Columns)
{
if (strval == "")
{
strval = dc.ColumnName + " ";
}
else
{
strval = strval + dc.ColumnName + " ";
}
}
rpthdr.AppendLiteralString(strval);
Repeater1.HeaderTemplate = rpthdr;
Repeater1.DataSource = ds;
Repeater1.DataBind();
}
VB.NET
C#
VB.NET
Sub BindData()
strConn="Server=localhost;uid=sa;password=;database=northwind;"
myconnection = New SqlConnection(strConn)
myda = New SqlDataAdapter(SQLStmt, myconnection)
ds = New DataSet
myda.Fill(ds, "AllTables")
Repeater1.DataSource = ds
Repeater1.DataBind()
End Sub 'BindData
C#
string SortField;
SqlConnection myconnection ;
SqlDataAdapter myda ;
DataSet ds ;
String strConn ;
string SQLStmt= "Select * from Employees ";
void BindData()
{
strConn="Server=localhost;uid=sa;password=;database=northwind;";
myconnection =new SqlConnection(strConn);
myda = new SqlDataAdapter(SQLStmt, myconnection);
ds = new DataSet();
myda.Fill(ds, "AllTables");
Repeater1.DataSource = ds;
Repeater1.DataBind();
}
The Repeater class is not derived from the WebControl class, like the DataGrid and DataList. Therefore, the
Repeater lacks the stylistic properties common to both the DataGrid and DataList. What this boils down to is
that if you want to format the data displayed in the Repeater, you must do so in the HTML markup. i.e using
<b>/<u>.. tags
8.7 How to change the row color of the Repeater based on some
condition?
VB.NET