DataGrid绑定结构

Header
1: System.Web.UI.WebControls.TableCell
    Controls Count:  3
        System.Web.UI.LiteralControl
        System.Web.UI.WebControls.TextBox
        System.Web.UI.LiteralControl
2: System.Web.UI.WebControls.TableCell
    Controls Count:  0
3: System.Web.UI.WebControls.TableCell
    Controls Count:  0
Item
1: System.Web.UI.WebControls.TableCell
    Controls Count:  3
        System.Web.UI.LiteralControl
        System.Web.UI.WebControls.CheckBox
        System.Web.UI.LiteralControl
2: System.Web.UI.WebControls.TableCell
    Controls Count:  0
3: System.Web.UI.WebControls.TableCell
    Controls Count:  0
Footer
1: System.Web.UI.WebControls.TableCell
    Controls Count:  0
2: System.Web.UI.WebControls.TableCell
    Controls Count:  0
3: System.Web.UI.WebControls.TableCell
    Controls Count:  0

-------------------

ID Name
1 first


-----------

private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
        
{
            Response.Write(e.Item.ItemType.ToString());
            Response.Write(
"<br>");

            
if(true)//e.Item.ItemType == ListItemType.Header)
            {
                
int i=1;
                
foreach( TableCell c in e.Item.Cells)
                
{
                    Response.Write( i.ToString() 
+ ""); 
                    i
++;
                    Response.Write( c.ToString() 
+ "<br>");
                    
int count = c.Controls.Count ;
                    Response.Write(
" &nbsp;&nbsp;&nbsp;&nbsp;Controls Count:&nbsp;  " + count.ToString() + "<br>");
                    
if(count>0)
                    
{
                        
foreach(Control ic in c.Controls)
                        
{
                            Response.Write(
"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
                            Response.Write(ic.ToString());
                            Response.Write(
"<br>");
                        }

                    }

                }

                
            }

        }

posted on 2006-11-06 14:32  YZG  阅读(333)  评论(1编辑  收藏  举报

导航