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

前台:
<asp:DataList ID="DataList1" runat="server" Width="100%" CellPadding="0"  DataKeyField="id">
<ItemTemplate>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="20" width="10%" class="but" align="center"><%# DataBinder.Eval(Container, "DataItem.fa_num ")%></td>
<td height="20" width="40%" class="but" align="center"><asp:Label ID="LabelInventory" runat="server" Text='<%# Eval("Inventory") %>'></asp:Label></td>
<td height="20" width="20%" class="but" align="center"><%# DataBinder.Eval(Container, "DataItem.selldata")%></td>
<td height="20" width="20%" class="but" align="center"><asp:Label ID="LabelZF" runat="server" Text='<%# Eval("ZF") %>'></asp:Label></td>
<td height="20px" width="10%" class="but" align="center"><asp:Label ID="LabelA" runat="server" Text="Label"></asp:Label></td>
</tr>
</table>                                   
</ItemTemplate>   
</asp:DataList>

后台:
    public void BindData()
    {
..............
        ss();
..............
    }

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

   
     


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