当前位置: 代码迷 >> ASP.NET >> 用hashtable做数据源的有关问题
  详细解决方案

用hashtable做数据源的有关问题

热度:1602   发布时间:2013-02-25 00:00:00.0
用hashtable做数据源的问题
Hashtable hs = new Hashtable();
  。。。。。。
  ViewState["hs1"] = hs;
  GridView1.DataSource = hs;
  GridView1.DataBind();
调试了,hs里有表中的数据,但是执行到GridView1.DataBind();这句时却提示:“ID 为“GridView1”的 GridView 的数据源没有任何可用来生成列的属性或特性。请确保您的数据源有内容。”,可调试的时候datasource是hs,里面有数据呢?请问这是什么问题呢?谢了


------解决方案--------------------------------------------------------
C# code
前台<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false">            <Columns>                <asp:BoundField DataField="Key" HeaderText="Key" />                <asp:BoundField DataField="Value" HeaderText="Value" />            </Columns>         </asp:GridView>
------解决方案--------------------------------------------------------
探讨

C# code

前台
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="Key" HeaderText="Key" />
<asp:Bo……
  相关解决方案