Binding a datagrid to a System.Collections member

S

Sathyaish

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top