文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>服务器端获取gridview中的

服务器端获取gridview中的

时间:2011-05-19  来源:fc5110

前台:

 <asp:GridView ID="gridViewListNew" runat="server" AutoGenerateColumns="False" AllowSorting="True"
                OnSorting="GridViewListSorting" DataKeyNames="FamiliesID" Visible="false" OnRowDataBound="GridViewNew_RowDataBound"
                ClientIDMode="Static" CssClass="jqGrid">
                <Columns>
                    <asp:TemplateField HeaderText="选择">
                        <ItemTemplate>
                            <asp:HiddenField ID="hdfCountieID" runat="server" Value='<%#Eval("CountieID") %>' />
                            <asp:HiddenField ID="hdfTownShipID" runat="server" Value='<%#Eval("TownShipID") %>' />
                            <asp:HiddenField ID="hdfVillageID" runat="server" Value='<%#Eval("VillageID") %>' />
                            <asp:HiddenField ID="hdfGroupID" runat="server" Value='<%#Eval("GroupID") %>' />
                            <asp:RadioButton ID="rbFamily" AutoPostBack="true" OnCheckedChanged="rbFamily_CheckedChanged"
                                runat="server" />
                        </ItemTemplate>
                        <HeaderStyle CssClass="alignCenter" Width="50px" />
                    </asp:TemplateField>

  <Columns>
 </asp:GridView>

后台更改事件:

 /// <summary>
        /// GridView_RedioButton单选事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void rbFamily_CheckedChanged(object sender, EventArgs e)
        {
            RadioButton rdo = (RadioButton)sender;
            TableCell cell = (TableCell)rdo.Parent;
            GridViewRow gridrow = (GridViewRow)cell.Parent;
            for (int i = 0; i < gridViewListNew.Rows.Count; i++)
            {
                if (i != gridrow.RowIndex)
                {
                    RadioButton rbt = gridViewListNew.Rows[i].FindControl("rbFamily") as RadioButton;
                    rbt.Checked = false;
                }
            }
        }

后台获取事件:

 for (int i = 0; i <= gridViewListNew.Rows.Count - 1; i++)
            {
                RadioButton rb = (RadioButton)gridViewListNew.Rows[i].FindControl("rbFamily");
                if (rb.Checked == true)
                {
                    hfNewFamilyPrimayKeyId.Value = "";
                    hfNewFamilyPrimayKeyId.Value = gridViewListNew.DataKeys[i].Value.ToString();
                }
            }

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载