ItemTemplate in a repeater : Repeater « Asp Control « ASP.Net






ItemTemplate in a repeater

<%@ Page %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">

    Sub Page_Load(sender as Object, e as EventArgs)
       Const strConnString as String = "server=localhost;uid=sa;pwd=;database=pubs"
       Dim objConn as New SqlConnection(strConnString)
    
      Const strSQL as String = "SELECT * FROM authors"
      Dim objCmd as New SqlCommand(strSQL, objConn)
    
      Dim objDA as New SqlDataAdapter()
      objDA.SelectCommand = objCmd
    
      Dim objDS as New DataSet()
      objDA.Fill(objDS)
      objConn.Close()
    
      rptAuthors.DataSource = objDS
      rptAuthors.DataBind()
    End Sub

</script>
<asp:repeater id="rptAuthors" runat="server">
  <HeaderTemplate>
    <table id="dlAuthors">
  </HeaderTemplate>
  
  <ItemTemplate>
    <tr>
      <td>
        <b><%# DataBinder.Eval(Container.DataItem, "au_lname") %>,
        <%# DataBinder.Eval(Container.DataItem, "au_fname") %></b>
      </td>
    </tr>
  </ItemTemplate>
  
  <FooterTemplate>
    </table>
  </FooterTemplate>
</asp:repeater>

 








Related examples in the same category

1.Repeater data binding
2.SeparatorTemplate in a repeater
3.SelectedItemTemplate in repeater