how to bind hash table to gridview
hi i have a hash table with following set of values
int ID 1
string Name ram
list date 2/3/2011
5/3/2011
Code:
<asp:TemplateField HeaderText="ID">
<ItemStyle Width="200px"> </ItemStyle>
<ItemTemplate>
<asp:Label ID="lblID" runat="server" Text='<%# Bind("ID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateFie开发者_Python百科ld>
its throws error in bind statement
You need to add a Repeator
or GridView
or Datalist
control to bind the list
(dates) inside the ItemTemplate
of GridView
.
Hash tables have keys
and values
so you can't bind your grid using the key names (as you are doing) because the key names are not properties of the hash table. If anything, you could have columns bound to Key
and Value
; however, your data has a List
of things (dates) and the Gridview won't know how to bind this list to one column. As AVD suggested, you need to have an item template and inside it, have another gridview if you want to bind a data structure like this to a grid view.
精彩评论