Hi Chad,
Teemu has a great answer. You can also use the repeater's ItemDataBound
event. This event fires for each row in the repeater (one by one).
Here's a small sample that demonstrates a little of what you can do in this
event.
*** Here is my repeater control
<asp:Repeater id="Repeater1" runat="server">
<ItemTemplate>
<input id=one name=one type=text runat=server value=
'<%# Container.DataItem("au_id")%>'>
<br>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:Repeater>
*** Here is my code
Dim Counter As Integer = 0
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Bind()
End If
End Sub
Private Sub Bind()
Dim Qry1 As System.Data.SqlClient.SqlDataReader
Dim connectionString As String = "server='localhost';
trusted_connection=true; Database='pubs'"
Dim sqlConnection As System.Data.SqlClient.SqlConnection = New
System.Data.SqlClient.SqlConnection(connectionString)
Dim queryString As String = "SELECT au_id, au_lname, au_fname FROM
authors"
Dim sqlCommand As System.Data.SqlClient.SqlCommand = New
System.Data.SqlClient.SqlCommand(queryString, sqlConnection)
sqlConnection.Open()
Qry1 =
sqlCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
Repeater1.DataSource = Qry1
Repeater1.DataBind()
Qry1.Close()
sqlCommand.Dispose()
sqlConnection.Close()
sqlConnection.Dispose()
End Sub
Private Sub Repeater1_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.RepeaterItemEventArgs) Handles
Repeater1.ItemDataBound
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
If e.Item.DataItem("au_lname") = "Green" Then
Dim l As LinkButton = New LinkButton
l.Text = e.Item.DataItem("au_lname")
l.ForeColor = System.Drawing.Color.Green()
e.Item.Controls.Add(l)
End If
Counter += 1
End If
If e.Item.ItemType = ListItemType.Footer Then
Dim t As TextBox = New TextBox
t.Text = Counter.ToString & " People"
t.ForeColor = System.Drawing.Color.Green()
t.ReadOnly = True
e.Item.Controls.Add(t)
End If
End Sub
I hope this helps.
Thank you, Mike
Microsoft, ASP.NET Support Professional
Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three straightforward
steps listed to improve your computer’s security.
This posting is provided "AS IS", with no warranties, and confers no rights.
--------------------