日期:2014-05-17  浏览次数:20443 次

为什么这段代码的的checkbox没有设置为autopostback=true却可以改变checkbox.checked属性
我觉得很奇怪:
为什么这段代码的的checkbox没有设置为autopostback=true却可以改变checkbox.checked属性???
代码里面的 <asp:CheckBox ID="chkItem" runat="server"   /> 明明就没有autopostback,但为什么
后台的
 for (int i = 0; i < this.Repeater1.Items.Count; i++)
            {
                CheckBox cbox = (CheckBox)this.Repeater1.Items[i].FindControl("chkItem");
                if (cbox.Checked == true)
..................................             
}
却可以读出checked==true
好奇怪,求解释!!



/////////////////////前台


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="PagedDataSourceTest.WebForm2" %>

<!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>Repeater控件使用</title>
</head>
<body>
    <form id="form1" runat="server">
    <div style="margin-bottom: 20px; text-align: center; width: 1006px;">
        Repeater控件使用</div>
    <asp:Repeater ID="Repeater1" runat="server">
        <HeaderTemplate>
            <table border="1" cellpadding="0" cellspacing="0" style="width: 1006px; border-collapse: collapse;
                text-align: center;">
                <tr>
                    <td style="background-color: #cccccc; font-weight: bold; height: 25px;">
                        选择
                    </td>
                    <td style="background-color: #cccccc; font-weight: bold; height: 25px;">
                        id隐藏
                    </td>
                    <td style="background-color: #cccccc; font-weight: bold; height: 25px;">
                        货物名