js:
    <script type="text/javascript">
        function SelectAll(target)
        {
            var GridView1 = document.getElementById("<%=gvStudentTrainingCourse.ClientID %>");
            for(i = 1;i < GridView1.rows.length; i++)
            {
                if(GridView1.rows[i].cells[0].getElementsByTagName("INPUT")[0].disabled!=true)      //若有不可用CheckBox,则全选时不选
                {
                    GridView1.rows[i].cells[0].getElementsByTagName("INPUT")[0].checked = target.checked;
                }
            }
        }
    </script>
Html:
<asp:TemplateField>
      <HeaderTemplate>
            <input id="chkSelectAll" runat="server" type="checkbox" onclick="SelectAll(this)" title="全选" />
      </HeaderTemplate>
      <ItemTemplate>
            <asp:CheckBox ID="chkSelect" runat="server" DataKey='<%#Eval("TrainingCourseID") %>' />
      </ItemTemplate>
      <ItemStyle CssClass="tlink_pic" />
</asp:TemplateField>
posted on 2009-08-06 09:51  Machine Lee  阅读(211)  评论(0编辑  收藏  举报