当前位置: 代码迷 >> ASP.NET >> ((CheckBox)this.DataGrid1.Items[i].Cells[4].Controls[1]) 获取不了东西,该怎么解决
  详细解决方案

((CheckBox)this.DataGrid1.Items[i].Cells[4].Controls[1]) 获取不了东西,该怎么解决

热度:10495   发布时间:2013-02-26 00:00:00.0
((CheckBox)this.DataGrid1.Items[i].Cells[4].Controls[1]) 获取不了东西
cs   :

                ArrayList   alist   =   new   ArrayList();
                System.Web.UI.WebControls.CheckBox   box;
                for   (int   i   =   0;   i   <   DataGrid1.Items.Count;   i++)
                {
                        box   =   ((CheckBox)this.DataGrid1.Items[i].Cells[4].Controls[1]);
                        if   (box.Checked)
                        {
                                Response.Write(box.Text);
                        }
                }


aspx:

<%@   Page   Language= "C# "   AutoEventWireup= "true "   CodeFile= "invete_retify2.aspx.cs "   Inherits= "admin_cus_manage_invete_retify2 "   %>

<!DOCTYPE   html   PUBLIC   "-//W3C//DTD   XHTML   1.0   Transitional//EN "   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

<html   xmlns= "http://www.w3.org/1999/xhtml "   >
<head   runat= "server ">
        <title> yy3721后台管理 </title>
       
        <link   href= "../style/sys_edit_admin.css "   rel= "stylesheet "   type= "text/css "/>
                <script   type= "text/javascript ">

function   selectChk(flag)
{
var   element;
var   i;
element   =   document.all;
if(flag)
{
for(i   =   0;i   <   element.length;i   ++)
{
if(element[i].tagName   ==   "INPUT "   &&   element[i].type   ==   "checkbox ")
{
element[i].checked   =   true;
}
}
}
else
{
for(i   =   0;i   <   element.length;i   ++)
{
if(element[i].tagName   ==   "INPUT "   &&   element[i].type   ==   "checkbox ")
{
element[i].checked   =   false;
}
}
}
}
</script>
</head>
<body>
        <form   id= "form1 "   runat= "server "   action= "invete_retify2.aspx ">
     
                <table   align= "center "   border= "1 "   cellpadding= "0 "   cellspacing= "0 "   width= "703 ">
                        <tr>
                                <td   colspan= "2 "   style= "height:   50px ">
  相关解决方案