You can populate a 'DataTable' with your data then bind that to the gridview (you can programatically add rows to the datatable).
i.e
Code:Imports System.Data Private Sub BindData() gridview1.DataSource = GetData() gridview1.DataBind() End Sub Protected Function FormatDataTable() as DataTable Dim dt as DataTable = New DataTable() ' Create Columns dt.Columns.Add("id", System.Type.GetType("System.String")) dt.Columns.Add("text", System.Type.GetType("System.String")) Return dt End Function Protected Function GetData() as DataTable Dim dt as DataTable = FormatDataTable() Dim dr as DataRow ' Populate the datatable with your data (put this in appropriate loop) dr = dt.NewRow dr("id") = "1" dr("txt") = "Hi" ' Add the row dt.Rows.Add(dr) dt.AcceptChanges Return dt End Function![]()




Reply With Quote