Data Binding ASP.Net

<%@ Page Language="vb" %>
<%@ Import Namespace="System.Data" %>


   Databound Control Example
   
      Sub Page_Load()
         MyDataGrid.DataSource = CreateData()
         MyDataGrid.DataBind()
         MyDataList.DataSource = CreateData()
         MyDataList.DataBind()
         MyRepeater.DataSource = CreateData()
         MyRepeater.DataBind()
      End Sub
      Function CreateData() As DataTable
         Dim DT As New DataTable()
         Dim Row1, Row2, Row3, Row4 As DataRow
         DT.Columns.Add(New DataColumn("name", System.Type.GetType("System.String")))
         DT.Columns.Add(New DataColumn("city", System.Type.GetType("System.String")))
         Row1 = DT.NewRow()
         Row1("name") = "Name 1"
         Row1("city") = "City 1"
         DT.Rows.Add(Row1)
         Row2 = DT.NewRow()
         Row2("name") = "Name 2"
         Row2("city") = "City 2"
         DT.Rows.Add(Row2)
         Row3 = DT.NewRow()
         Row3("name") = "Name 3"
         Row3("city") = "City 3"
         DT.Rows.Add(Row3)
         Row4 = DT.NewRow()
         Row4("name") = "Name 4"
         Row4("city") = "City 4"
         DT.Rows.Add(Row4)
         Return DT
      End Function
   


   

Databound Control Example


   
      
         
            
               DataGrid Control:
            
            
                                 allowpaging="true"
                  allowsorting="true"
                  alternatingitemstyle-backcolor="LightSkyBlue"
                  backcolor="Blue"
                  forecolor="White"
                  cellpadding="2"
                  cellspacing="0"
                  headerstyle-backcolor="DarkBlue"
                  headerstyle-forecolor="Yellow"
                  pagerstyle-mode="NumericPages"
                  pagesize="5"
                  runat="server"/>
            
         
         
            
               DataList Control:
            
            
                                 alternatingitemstyle-backcolor="LightSkyBlue"
                  backcolor="Blue"
                  bordercolor="Black"
                  cellpadding="2"
                  cellspacing="0"
                  forecolor="White"
                  headerstyle-backcolor="DarkBlue"
                  headerstyle-forecolor="Yellow"
                  repeatcolumns="1"
                  repeatdirection="vertical"
                  repeatlayout="table" 
                  runat="server">
                  
                     Composers
                  

                  
                     <%# databinder.eval(container.dataitem, "name") %>
                  

               
            
         
         
            
               Repeater Control:
            
            
               
                  
                     
                        
                           Name

                           City

                        
                  

                  
                        
                           <%# DataBinder.Eval(Container.DataItem, _
                                  "name") %>
                           <%# DataBinder.Eval(Container.DataItem, _
                                  "city") %>