checkbox全选

<yyc:SmartGridView ID="gvInfo" runat='server' AutoGenerateColumns="False" AllowPaging="True"
                                    ContextMenuCssClass="RightMenu" OnPageIndexChanging="gvInfo_PageIndexChanging"
                                    MouseOverCssClass="OverRow" PageSize="10" Width="96%" DataKeyNames="TempletNo">
                                    <Columns>
                                        <asp:TemplateField>
                                            <HeaderTemplate>
                                                <asp:CheckBox ID="chkall" runat="server" onclick="SelectAllItem(gvInfo,this)" />
                                            </HeaderTemplate>
                                            <ItemTemplate>
                                                <asp:CheckBox ID="chk" runat="server" />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:BoundField DataField="TempletNo" HeaderText="序号" ItemStyle-HorizontalAlign="Center" />
                                        <asp:TemplateField HeaderText="模板描述" ItemStyle-HorizontalAlign="Center">
                                            <ItemTemplate>
                                                <asp:LinkButton ID="lbtnTempletText" runat="server" CommandArgument='<%#Eval("TempletNo") %>'
                                                    Text='<%#Eval("TempletText") %>' OnCommand="TempletText_Command"></asp:LinkButton>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:BoundField DataField="DeptName" HeaderText="诊断科室" ItemStyle-HorizontalAlign="Center" />
                                        <asp:BoundField DataField="Name" HeaderText="诊断医生" ItemStyle-HorizontalAlign="Center" />
                                        <asp:BoundField DataField="Dept" HeaderText="诊断科室ID" ItemStyle-HorizontalAlign="Center" />
                                        <asp:BoundField DataField="Doctor" HeaderText="诊断医生ID" ItemStyle-HorizontalAlign="Center" />
                                    </Columns>
                                    <EmptyDataTemplate>
                                        无记录。
                                    </EmptyDataTemplate>
                                    <HeaderStyle ForeColor="Black" BorderStyle="Double" />
                                    <CustomPagerSettings PagingMode="Webabcd" TextFormat="每页{0}条/共{1}条&nbsp;&nbsp;&nbsp;&nbsp;第{2}页/共{3}页&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" />
                                    <PagerSettings Position="Top" PageButtonCount="13" FirstPageText="首页" PreviousPageText="上一页"
                                        NextPageText="下一页" LastPageText="末页" />
                                </yyc:SmartGridView>


function SelectAllItem(table,checkAll)  //table为gridviewID, checkAll 为CheckBox控件
        {
            for(var i = 0; i < form1.elements.length; i++)
            {
                var e = form1.elements[i];
                if(e.type != null && e.type.toLowerCase() == "checkbox" && e.parentElement.parentElement.parentElement.parentElement.id==table.id)  //gridview里的所有checkbox是否全部选种
                {
                    e.checked = checkAll.checked;
                }
            }
        }
posted @ 2009-04-08 13:26  智者生存  阅读(208)  评论(0编辑  收藏  举报