触摸屏租赁
Touch screen rental
广告机租赁
Advertising rental
机器人租赁
Robot leasing
 当前位置:首页 > > 获取GridView中的控件值(应用于结存)

获取GridView中的控件值(应用于结存)

前台:
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AutoGenerateColumns="False" onpageindexchanging="GridView1_PageIndexChanging"
onrowdeleting="GridView1_RowDeleting"
style="margin-right: 0px"  ShowHeader="False" BorderWidth="0px" CellPadding="0" Width="100%" PageSize="30" >
<PagerSettings FirstPageText="第一页" LastPageText="最后一页" Mode="NextPreviousFirstLast"
NextPageText="下一页" PreviousPageText="上一页" />
<Columns>
<asp:TemplateField HeaderText="审核">
<ItemTemplate>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="20" width="5%" class="but" align="center" ><%# DataBinder.Eval(Container, "DataItem.up_date", "{0:d}")%></td>
<td height="20" width="5%" class="but" align="center" ><%# DataBinder.Eval(Container, "DataItem.username")%></td>
<td height="20" width="5%" class="but" align="center" ><%# DataBinder.Eval(Container, "DataItem.dept")%></td>
<td height="20" width="5%" class="but" align="center" ><%# DataBinder.Eval(Container, "DataItem.title", "{0:d}")%></td>
<td height="20" width="10%" class="but" align="left" ><%#   DataBinder.Eval(Container.DataItem, "content").ToString().Replace("\r\n", "<br/>").Replace(" ", "&nbsp;&nbsp;")%></td>
<td height="20" width="5%" class="but" align="center" ><asp:Label ID="Amount1" runat="server" Text='<%#Eval("Amount")%>'></asp:Label></td>
<td height="20" width="5%" class="but" align="center" ><asp:Label ID="LabelA" runat="server" Text="Label"></asp:Label></td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<SelectedRowStyle Font-Bold="False" />
<PagerStyle HorizontalAlign="Left" />
<HeaderStyle Font-Bold="False" />
</asp:GridView>

后台:
    public void BindData()
    {
        Conn conn = new Conn();
        try
        {
..............
        ss();
..............
    }

    protected void ss()
    {
        float Labelnum = 0;
        for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
        {
            Labelnum += Convert.ToSingle(((Label)GridView1.Rows[i].FindControl("Amount1")).Text);
            ((Label)this.GridView1.Rows[i].FindControl("LabelA")).Text = Labelnum.ToString();
        }
    }


工作室地址:重庆石桥铺电脑城B座 | 微信:z35544216 | 网址:www.35544216.com