The following ASPX code creates a dynamic DataSet which is then displayed in a DataGrid (using a DataView):
As such, the above code, when executed in IE 6, gets executed as expected i.e. the page shows a table having 3 columns: ID, FName & LName & only 1 row of record: 0, George, Michael. How do I add more records in this DataGrid? For e.g. I want the 2nd row records as: 1, Andre, Agassi; the 3rd row as: 2, Steffi, Graf; the 4th record as: 3, Carl, Lewis so on & so forth...
Please note that the records are not being retrieved from a database table; they have been (& have to be) added manually as shown above! I am a newbie as well
Thanks,
Arpan
Code:
[COLOR=brown]<script language=VB>
Sub Page_Load(obj As Object,ea As EventArgs)
Dim objDS As New DataSet
Dim objDT As New DataTable("Users")
objDT.Columns.Add("ID",System.Type.GetType("System.Int32"))
objDT.Columns.Add("FName",System.Type.GetType("System.String"))
objDT.Columns.Add("LName",System.Type.GetType("System.String"))
objDT.Columns("ID").AutoIncrement=True
objDS.Tables.Add(objDT)
Dim objDR As DataRow=objDT.NewRow()
objDR(1)="George"
objDR(2)="Michael"
objDT.Rows.Add(objDR)
Dim objDV As New DataView
objDV.Table=objDS.Tables("Users")
myDataGrid.DataSource=objDV
myDataGrid.DataBind()
End Sub
</script>
<asp:DataGrid id="myDataGrid" runat=server/>
[/color]
Please note that the records are not being retrieved from a database table; they have been (& have to be) added manually as shown above! I am a newbie as well
Thanks,
Arpan