• JavaScript 取GridView选择的 DataKeyNames


    ......
      //设置选中产品值
            function SetSelProductID() {
                var selectCount = 0;
                var productID = "";
                var productType = "";
                var productName = "";
                var lblProductName = document.getElementById("lblSelProductName");
                var hidProductID = document.getElementById("hidProductID");
                var inputs = document.getElementById("<%=GridView1.ClientID%>").getElementsByTagName("input");
                lblProductName.innerText = "";
                hidProductID.value = "";
                for (var i = 0; i < inputs.length; i++) {
                    if (inputs[i].type == "checkbox" && inputs[i].checked) {
                        productID = inputs[i].parentElement.parentElement.lastChild.innerText;
                        productName = inputs[i].parentElement.parentElement.childNodes[2].innerText;
                        productType = inputs[i].parentElement.parentElement.childNodes[6].innerText;                    
                        if (lblProductName.innerText == "") {
                            lblProductName.innerText = productName;
                            hidProductID.value = productID + "," + productType;
                        } else {
                            lblProductName.innerText = lblProductName.innerText + ";" + productName;
                            hidProductID.value = hidProductID.value + ";" + productID + "," + productType;
                        }
                    }
                }
            }
      ......
      <asp:GridView ID="GridView1" runat="server" AllowPagerable="False"
                AllowChangeCellWidth="True"   AutoGenerateColumns="False"
            CellPadding="0" DataKeyNames="ID" GridLines="None"
            CssClass="gridviewStyle" JumpButtonHeight="25px" JumpButtonWidth="25px"
                onrowdatabound="GridView1_RowDataBound" >
            <Columns>
      <asp:TemplateField HeaderText="选择">
                    <ItemStyle CssClass="gridview_itemStyle" Width="40px" HorizontalAlign="Center"/>
                    <HeaderStyle CssClass="gridview_headerStyle" Width="40px"/>
                    <ItemTemplate>
                        <input id="Checkbox1" type="checkbox" onclick ="SetSelProductID();" />                                  
                    </ItemTemplate>
                </asp:TemplateField>    
      ......
      <asp:TemplateField HeaderText="产品类别2">
                        <ItemStyle CssClass="gridview_hiddenItemStyle" HorizontalAlign="left" Width="0px" />
                         <HeaderStyle CssClass="gridview_hiddenItemStyle" Width="0px" />
                        <ItemTemplate>
                            <asp:Label ID="lblType2" runat="server" Text='<%#  Eval("ProductCategory") %>'></asp:Label></ItemTemplate>                     
                        </asp:TemplateField>
                 <asp:BoundField DataField="ProductID" HeaderText="产品ID">
                        <ItemStyle CssClass="gridview_hiddenItemStyle" HorizontalAlign="left" Width="0px" />
                        <HeaderStyle CssClass="gridview_hiddenItemStyle" Width="0px" />                 
                 </asp:BoundField>   
            </Columns>
            <RowStyle CssClass="gridview_rowStyle" />
            <AlternatingRowStyle CssClass="gridview_alternatingRowStyle" />
            <EmptyDataTemplate>
                <table class="itemtable" cellspacing="1" cellpadding="2" border="0">
                    <tbody>
                        <tr class="toplinebg">
                            <td width="40px" height="20">选择</td>
                            <td width="60px">序号</td>
                            <td width="100px">产品编号</td>
                            <td width="180px">产品名称</td>
                              <td width="60px">产品状态</td>
                                <td width="60px">所属分公司</td>
                                <td width="100px">产品类别</td>
                        </tr>
                          <tr >
                            <td  height="20" class="gridview_itemStyle2" colspan="7">暂无信息</td>                      
                        </tr>
                    </tbody>
                </table>
            </EmptyDataTemplate>
        </asp:GridView>

    css里的样式:
    .gridview_hiddenItemStyle
    {
        display:none;
    }
  • 相关阅读:
    kernel structure
    linux cmd fuser/screen
    arm 指令架构
    udev 学习
    grup 2 ubuntu
    tiny6410 3.8.1 内核kgdb调试
    make 选项
    lfs 无知
    数据归一化的两种方法:最值归一化和0均值归一化
    使用随机队列实现生成迷宫
  • 原文地址:https://www.cnblogs.com/ylemzhang/p/1564114.html
Copyright © 2020-2023  润新知