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">
                    招商信息认证</td>
            </tr>
            <tr>
                <td align="center" class="add_manage_text" style="width: 256px; height: 35px">
                    搜索类型:<asp:DropDownList ID="DropDownList1" runat="server" Width="105px">
                        <asp:ListItem Value="[User_name]">会员名称</asp:ListItem>
                        <asp:ListItem Value="Business_name">产品名称</asp:ListItem>
                        <asp:ListItem Value="Business_company">公司名称</asp:ListItem>
                    </asp:DropDownList></td>
                <td style="height: 35px; width: 339px;">
                    关键字:<asp:TextBox ID="TextBox1" runat="server" Width="105px"></asp:TextBox>&nbsp; &nbsp;
                    <asp:Button ID="Button1" runat="server" OnClick="Button1_Click1" Text="搜 索" /></td>
            </tr>
            <tr>
                <td colspan="2" rowspan="2" style="height: 344px" valign="top">
                    <p align="center">
                    
                        <asp:DataGrid ID="DataGrid1" runat="server" AllowPaging="True" AlternatingItemStyle-BackColor="#eeeeee"
                            AutoGenerateColumns="False" BorderColor="Black" BorderWidth="1px" CellPadding="3"
                            Font-Name="Verdana" Font-Names="Verdana" Font-Size="8pt" HeaderStyle-BackColor="#aaaadd"
                            HorizontalAlign="Justify"  PagerStyle-HorizontalAlign="Right"
                            PagerStyle-Mode="NumericPages" OnPageIndexChanged="DataGrid1_PageIndexChanged" Height="30px" Width="100%">
                            
                          
                           <Columns>
                            <asp:BoundColumn DataField="business_name" HeaderText="产品"></asp:BoundColumn>
                            <asp:BoundColumn DataField="user_name" HeaderText="会员"></asp:BoundColumn>
                            <asp:BoundColumn DataField="business_company" HeaderText="公司名称"></asp:BoundColumn>
                            <asp:BoundColumn DataField="business_issuance" DataFormatString="{0:yyyy-MM-dd hh:mm:ss}" HeaderText="发布时间"></asp:BoundColumn>
                          <asp:TemplateColumn HeaderText="选择">
                            <ItemTemplate>
                               <asp:CheckBox ID="CheckBox1" runat="server"  Text='<%# DataBinder.Eval(Container.DataItem,"business_id") %>'/>       
                                 </ItemTemplate>
                              <HeaderTemplate>
                                  选择
                              </HeaderTemplate>
                               </asp:TemplateColumn>
                          </Columns>
                            <PagerStyle HorizontalAlign="Right" Mode="NumericPages" />
                            <AlternatingItemStyle BackColor="#EEEEEE" />
                            <HeaderStyle BackColor="#AAAADD" />
                      
                          
                          
                          
                        </asp:DataGrid>
                        <asp:LinkButton ID="LinkButton1" Font-Name="verdana" Font-size="8pt" OnClick="LinkButton1_Click" runat="server">LinkButton</asp:LinkButton>
                        <asp:LinkButton ID="LinkButton2" Font-Name="verdana" Font-size="8pt" OnClick="LinkButton2_Click" runat="server">LinkButton</asp:LinkButton>
                        <asp:LinkButton ID="LinkButton3" Font-Name="verdana" Font-size="8pt" OnClick="LinkButton3_Click" runat="server">LinkButton</asp:LinkButton>
                        <asp:LinkButton ID="LinkButton4" Font-Name="verdana" Font-size="8pt" OnClick="LinkButton4_Click" runat="server">LinkButton</asp:LinkButton>
                        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                        &nbsp; &nbsp;<asp:Label ID="Label1" Font-Name="verdana" Font-size="8pt" runat="server" Text="Label"></asp:Label>
                        &nbsp; &nbsp;
                        <asp:Label ID="Label2" Font-Name="verdana" Font-size="8pt" runat="server" Text="Label"></asp:Label></p>
                    
                    </td>
            </tr>
            <tr>
            </tr>
            <tr>
                <td align="center" colspan="2" style="height: 35px">
                    <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="认 证" />
                    &nbsp;&nbsp; &nbsp;
                    
                    <input id="Button3" type="button" value="全 选" language="javascript" onclick="selectChk(true)" />
                    &nbsp;&nbsp; &nbsp;<input id="Button4" type="button" value="取 消" language="javascript" onclick="selectChk(false)" />
                    </td>
            </tr>
        &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;
        </table>
    
 
    </form>
</body>
</html>

解决方案 »

  1.   

    ((CheckBox)this.DataGrid1.Items[i].Cells[4].Controls[1]) 会不会是Controls[0]?
      

  2.   

    <ItemTemplate>
                                   <asp:CheckBox ID="CheckBox1" runat="server"  Text='<%# DataBinder.Eval(Container.DataItem,"business_id") %>'/>       
                                     </ItemTemplate>
    ----------
    从这里来看应该是((CheckBox)this.DataGrid1.Items[i].Cells[4].Controls[0])
      

  3.   

    你也可以用findcontrol方法for (int i = 0; i < DataGrid1.Items.Count; i++)
            {
                box = ((CheckBox)this.DataGrid1.Items[i].Cells[4].findcontrol("CheckBox1"));
                if (box.Checked)
                {
                    Response.Write(box.Text);
                }
            }
      

  4.   

    ((CheckBox)this.DataGrid1.Items[i].Cells[4].findcontrol("CheckBox1"));这个也不行啊~~~
      

  5.   

    ((CheckBox)this.DataGrid1.Items[i].findcontrol("CheckBox1"));
      

  6.   

    box = ((CheckBox)this.DataGrid1.Items[i].Cells[4].FindControl("CheckBox1"));
    这个也不行。。~ 我估计不是这儿的错。。好想是aspx 里面的事
      

  7.   

    最好用((CheckBox)this.DataGrid1.Items[i].findcontrol("CheckBox1"));