码迷,mamicode.com
首页 > 其他好文 > 详细

Reperter中嵌套GridView中后台代码的遍历

时间:2015-02-11 12:29:18      阅读:135      评论:0      收藏:0      [点我收藏+]

标签:

前台代码如下:  <asp:Repeater ID="RepBigClass" runat="server">
                <ItemTemplate>
                    <div>
                        <h2 style="text-align: left;"><%#Eval("ClassTypeName") %></h2>
                        <asp:HiddenField ID="hiddgvsqlconte" Value=‘<%#GetAnd(Eval("ClassTypeName"))%>‘ runat="server" />
                        <asp:ObjectDataSource ID="objforgv" runat="server" SelectMethod="GetEntityListAll" TypeName="IETC.BLL.V_企业填写价格量指标表模板">
                            <SelectParameters>
                                <asp:Parameter DefaultValue="ProducID" Name="sortField" Type="String" />
                                <asp:Parameter DefaultValue="ASC" Name="sortOrder" Type="String" />
                                <asp:ControlParameter ControlID="hiddgvsqlconte" DefaultValue="" Name="condition" PropertyName="Value" Type="String" />
                            </SelectParameters>
                        </asp:ObjectDataSource>
                        <asp:GridView ID="gv" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#CC9966" BorderStyle="None" BorderWidth="1px" CellPadding="4" DataSourceID="objforgv">
                            <Columns>
                                <asp:BoundField DataField="ProducID" HeaderText="ProducID" Visible="False" />
                                <asp:BoundField DataField="项目名称" HeaderStyle-Width="175px" HeaderText="项目名称" ReadOnly="true">
                                    <HeaderStyle Width="175px"></HeaderStyle>
                                </asp:BoundField>
                                <asp:BoundField DataField="ClassType" HeaderText="ClassType" Visible="False" />
                                <asp:BoundField DataField="RepHeadType" HeaderText="RepHeadType" Visible="False" />
                                <asp:TemplateField HeaderText="本旬">
                                    <EditItemTemplate>
                                        <asp:TextBox ID="TextBox1" runat="server" Text=‘<%# Bind("本旬") %>‘></asp:TextBox>
                                    </EditItemTemplate>
                                    <ItemTemplate>
                                        <%--         <%#Eval("本旬") %>--%>
                                        <asp:TextBox ID="tbcurrent" runat="server"></asp:TextBox>
                                    </ItemTemplate>
                                    <HeaderStyle Width="175px" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="本旬此累计">
                                    <EditItemTemplate>
                                        <asp:TextBox ID="TextBox2" runat="server" Text=‘<%# Bind("本旬此累计") %>‘></asp:TextBox>
                                    </EditItemTemplate>
                                    <ItemTemplate>
                                        <%--  <%#Eval("本旬此累计") %>--%>
                                        <asp:TextBox ID="tbCurrentcount" runat="server"></asp:TextBox>
                                    </ItemTemplate>
                                    <HeaderStyle Width="175px" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="本旬此累计比去年同期比">
                                    <EditItemTemplate>
                                        <asp:TextBox ID="TextBox3" runat="server" Text=‘<%# Bind("本旬此累计比去年同期比") %>‘></asp:TextBox>
                                    </EditItemTemplate>
                                    <ItemTemplate>
                                        <%--                                               <%#Eval("本旬此累计比去年同期比") %>--%>
                                        <asp:TextBox ID="tblastofcurrent" runat="server"></asp:TextBox>
                                    </ItemTemplate>
                                    <HeaderStyle Width="250px" />
                                </asp:TemplateField>
                                <asp:BoundField DataField="校验" HeaderText="校验" HeaderStyle-Width="175px" ReadOnly="true">
                                    <HeaderStyle Width="175px"></HeaderStyle>
                                </asp:BoundField>                   
                            </Columns>
                            <FooterStyle BackColor="#FFFFCC" ForeColor="#330099" />
                            <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="#FFFFCC" />
                            <PagerStyle BackColor="#FFFFCC" ForeColor="#330099" HorizontalAlign="Center" />
                            <RowStyle BackColor="White" ForeColor="#330099" />
                            <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" />
                            <SortedAscendingCellStyle BackColor="#FEFCEB" />
                            <SortedAscendingHeaderStyle BackColor="#AF0101" />
                            <SortedDescendingCellStyle BackColor="#F6F0C0" />
                            <SortedDescendingHeaderStyle BackColor="#7E0000" />
                        </asp:GridView>
                    </div>
                </ItemTemplate>
            </asp:Repeater>

 

---------------------------------------------------

后台代码:

     foreach (RepeaterItem item in this.RepBigClass.Items)         //遍历Reperter 

            { 

             GridView grid = (GridView)item.FindControl("gv");   //先找到 Reperter下的GridView 

             int rowsCount = grid.Rows.Count;              

              for (int i = 0; i < rowsCount; i++)         //循环GridView     

              {   

               TextBox tbcurrent = (TextBox)grid.Rows[i].FindControl("tbcurrent");      

               TextBox tbCurrentcount = (TextBox)grid.Rows[i].FindControl("tbCurrentcount");          

                TextBox tblastofcurrent = (TextBox)grid.Rows[i].FindControl("tblastofcurrent");           

                string current = tbcurrent.Text;                   

                string Currentcount = tbCurrentcount.Text;           

                string lastofcurrent = tblastofcurrent.Text;       

                            }

            }

备注:通过此方法可以将所有的Input中的值获取到,已通过测试。

 

Reperter中嵌套GridView中后台代码的遍历

标签:

原文地址:http://www.cnblogs.com/Yunshine-sina/p/4285602.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!