<asp:DataGrid ID="dgItems" runat="server" DataSourceID="edsItems" EnableViewState="False" AutoGenerateColumns="False" BackColor="White" BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px" CellPadding="4" > <Columns> <asp:BoundColumn DataField="Name" HeaderText="Name"></asp:BoundColumn> <asp:BoundColumn DataField="Perc" HeaderText="Perc"></asp:BoundColumn> <asp:TemplateColumn > <HeaderTemplate> <asp:Label ID="lb" runat="server" Text="Dose Type" /> </HeaderTemplate> <ItemTemplate> <asp:Label ID="lbOne" runat="server" Text='<%# Bind("amounts_tb.field1")%>' /> </ItemTemplate> </asp:TemplateColumn> <asp:BoundColumn DataField="AmountSupplied" HeaderText="Amount Supplied"></asp:BoundColumn> <asp:BoundColumn DataField="VolumeSupplied" HeaderText="Volume Supplied"></asp:BoundColumn> <asp:BoundColumn DataField="Max" HeaderText="Max" ></asp:BoundColumn> <asp:TemplateColumn > <HeaderTemplate> <asp:Label ID="lbAmt" runat="server" Text="Amount" /> </HeaderTemplate> <ItemTemplate> <asp:Label ID="amt" runat="server" /> </ItemTemplate> </asp:TemplateColumn> <asp:TemplateColumn > <HeaderTemplate> <asp:Label ID="lbVol" runat="server" Text="Volume" /> </HeaderTemplate> <ItemTemplate> <asp:Label ID="vol" runat="server" /> </ItemTemplate> </asp:TemplateColumn> </Columns> <FooterStyle BackColor="#99CCCC" ForeColor="#003399" /> <HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" /> <ItemStyle BackColor="White" ForeColor="#003399" /> <PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" Mode="NumericPages" /> <SelectedItemStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" /> </asp:DataGrid>
Try Dim kg As Double If Double.TryParse(tbVariable.Text, kg) Then For row As Integer = 0 To dgItems.Items.Count - 1 Dim one, amt, max, amts, vols As Double one = CDbl(dgItems.Items(row).Cells(1).Text) amts = CDbl(dgItems.Items(row).Cells(3).Text) vols = CDbl(dgItems.Items(row).Cells(4).Text) max = CDbl(dgItems.Items(row).Cells(5).Text) amt = one * kg If amt > max Then amt = max Dim lbAmt As Label = TryCast(dgItems.Items(row).Cells(6).FindControl("amt"), Label) Dim lbVol As Label = TryCast(dgItems.Items(row).Cells(7).FindControl("vol"), Label) If Not lbAmt Is Nothing Then lbAmt.Text = Amount(amt, max) If Not lbVol Is Nothing Then lbVol.Text = Volume(amt, amts, vols) Next End If Catch ex As Exception Response.Write(ex.Message) End Try
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)