zoukankan      html  css  js  c++  java
  • hashtable 绑定的datagrid

    cs code
            protected System.Web.UI.WebControls.DataList datalist;
            Hashtable o 
    = new Hashtable();
            
    private void Page_Load(object sender, System.EventArgs e)
            
    {
                DataTable dt 
    = new DataTable();
                dt.Columns.Add(
    "saf");
                DataRow dr 
    = dt.NewRow();
                dr[
    0= "todd ha ha";
                dt.Rows.Add(dr);
                dr 
    = dt.NewRow();
                dr[
    0= "summy ha ha";
                dt.Rows.Add(dr);
                o.Add(
    1,dt);
                o.Add(
    2,dt);
                o.Add(
    3,dt);
                
    this.datalist.DataSource = o;
                
    this.datalist.DataBind();
            }

            
    private void datalist_ItemDataBound(object sender, System.Web.UI.WebControls.DataListItemEventArgs e)
            
    {
                DataGrid obj 
    = ((DataGrid)(e.Item.FindControl("datagridtest")));
                
    //object objItem = this.datalist.DataKeys[e.Item.ItemIndex];
                System.Collections.DictionaryEntry Entity = (System.Collections.DictionaryEntry)(e.Item.DataItem);
                DataTable bb 
    = ((DataTable)(Entity.Value));
                obj.DataSource    
    = bb;
                obj.DataBind();        
            }
    aspx code
        <asp:DataList ID="datalist" Runat="server"  DataKeyField ="key">
                    
    <ItemTemplate>
                        
    <asp:Label ID ="labeltest" Runat=server text='<%# DataBinder.Eval(Container, "DataItem.key")%>' >
                        
    </asp:Label>
                        
    <asp:DataGrid ID="datagridtest" Runat=server  ></asp:DataGrid>
                    
    </ItemTemplate>
                
    </asp:DataList>
  • 相关阅读:
    telnet退出
    Eclipse srever起来时,时间超过45s。
    maven报错 Failure to transfer org.apache.maven.plugins:maven-compiler-plugin:pom:3.5.0 from
    需求讨论
    PyTorch学习笔记之计算图
    PyTorch学习笔记之CBOW模型实践
    PyTorch学习笔记之n-gram模型实现
    PyTorch学习笔记之初识word_embedding
    7月3日-9日_周报
    python学习笔记之heapq内置模块
  • 原文地址:https://www.cnblogs.com/snowball/p/461406.html
Copyright © 2011-2022 走看看