DataGrid绑定结构

本文详细介绍了 ASP.NET 中 DataGrid 控件的使用方法,包括如何通过 ItemDataBound 事件处理程序遍历 DataGrid 的每一项,并获取其单元格内的控件数量及类型。这对于理解网页中表格数据的动态绑定过程非常有帮助。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

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

IDName
1first


-----------
None.gifprivate void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif{
InBlock.gif            Response.Write(e.Item.ItemType.ToString());
InBlock.gif            Response.Write(
"<br>");
InBlock.gif
InBlock.gif            
if(true)//e.Item.ItemType == ListItemType.Header)
ExpandedSubBlockStart.gifContractedSubBlock.gif
            dot.gif{
InBlock.gif                
int i=1;
InBlock.gif                
foreach( TableCell c in e.Item.Cells)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    Response.Write( i.ToString() 
+ ""); 
InBlock.gif                    i
++;
InBlock.gif                    Response.Write( c.ToString() 
+ "<br>");
InBlock.gif                    
int count = c.Controls.Count ;
InBlock.gif                    Response.Write(
" &nbsp;&nbsp;&nbsp;&nbsp;Controls Count:&nbsp;  " + count.ToString() + "<br>");
InBlock.gif                    
if(count>0)
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        
foreach(Control ic in c.Controls)
ExpandedSubBlockStart.gifContractedSubBlock.gif                        
dot.gif{
InBlock.gif                            Response.Write(
"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
InBlock.gif                            Response.Write(ic.ToString());
InBlock.gif                            Response.Write(
"<br>");
ExpandedSubBlockEnd.gif                        }

ExpandedSubBlockEnd.gif                    }

ExpandedSubBlockEnd.gif                }

InBlock.gif                
ExpandedSubBlockEnd.gif            }

ExpandedBlockEnd.gif        }

转载于:https://www.cnblogs.com/yizhinantian/archive/2006/11/06/551750.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值