PDA

Click to See Complete Forum and Search --> : Binding a datagrid to a System.Collections member


Sathyaish
Sep 5th, 2005, 09:28 PM
Ok, all I am doing is trying to bind a data grid to an IDictionary.
Here goes:

Sub Page_Load(sender As Object, e As EventArgs)
If Not IsPostBack() Then Call BindData()
End Sub

Public Sub BindData()
Dim Skl As New Hashtable
Skl.Add(1, "Visual C#")
skl.Add(2, "Visual Basic")
skl.Add(3, "Win32 API Programming")

dg.DataSource = skl
dg.DataBind()
End Sub

The error I get is:

System.Web.HttpException: DataGrid with id 'dg' could not automatically
generate any columns from the selected data source.

on the line:


dg.DataBind()

So, is there some special glue when you have to bind a datagrid to a
non-relational source such as IList or IDictionary or Hashtable?