title: How to split the string and databind to gridview?
body: <p>I need to databind the gridview in which the string come from other system.</p>
  
  <p>The format will like that:</p>
  
  <pre><code>A1|Peter|2011-01-01|2012-03-03|0;A9|Jacky|2011-10-01|2012-09-03|2;B3|Chris|2011-10-01|2012-09-03|2;
  </code></pre>
  
  <p>| as separator of column</p>
  
  <p>; as separator of next record</p>
  
  <p>Is there any method to do that ?</p>
  
  <p>Thanks.</p>
  
  <p>my code as below:</p>
  
  <pre><code>   Sub Call_Payroll(ByVal SNO As String)
  
  
          Dim theType As String = ""
  
          theType = xxxxxx &lt;- Get from Source
  
          Dim tList = theType.Split(";")
  
  
  
          Dim dt As New DataTable
  
          dt = ListToDataTable(tList)
  
          RadGrid_payroll.DataSourceID = ""
          RadGrid_payroll.DataSource = dt
          RadGrid_payroll.DataBind()
  
      End Sub
  
      Public Shared Function ListToDataTable(Of T)(ByVal list As List(Of T)) As DataTable
          Dim dt As New DataTable()
          For Each info As PropertyInfo In GetType(T).GetProperties()
              dt.Columns.Add(New DataColumn(info.Name, info.PropertyType))
          Next
          For Each T In list
              Dim row As DataRow = dt.NewRow()
              For Each info As PropertyInfo In GetType(T).GetProperties()
                  row(info.Name) = info.GetValue(T, Nothing)
              Next
              dt.Rows.Add(row)
          Next
          Return dt
      End Function
  </code></pre>