---This is the GridView Code---
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDataSource1" CssClass="GridViewStyle"
DataKeyNames="item_id" DataMember="DefaultView" ShowFooter="True"
AllowSorting="True" >
<RowStyle CssClass="RowStyle" />
<EmptyDataRowStyle CssClass="EmptyRowStyle" />
<PagerStyle CssClass="PagerStyle" />
<SelectedRowStyle CssClass="SelectedRowStyle" />
<HeaderStyle CssClass="HeaderStyle" />
<EditRowStyle CssClass="EditRowStyle" />
<AlternatingRowStyle CssClass="AltRowStyle" />
<Columns>
<asp:BoundField DataField="item_id" HeaderText="Item ID"
SortExpression="item_id" />
<asp:TemplateField>
<ItemTemplate>
<div>
<a href="#" onclick="openRadWindow('http://search.com'); return false;">
<img src='<%# Eval("Item_Image") %>' height="20px" /></a>
</div>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="unit_of_measure" HeaderText="Unit of Measure"
SortExpression="unit_of_measure" />
<asp:BoundField DataField="item_desc" HeaderText="Item Description"
SortExpression="item_desc" />
<asp:BoundField DataField="Last Order Date" DataFormatString="{0:d}"
HeaderText="Last Invoice Date" SortExpression="Last Order Date" />
<asp:TemplateField HeaderText="Price" SortExpression="unit_price">
<ItemTemplate>
<asp:Label ID="Price" runat="server" Text='<%# Bind("unit_price", "{0:c}") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("unit_price") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Qty">
<ItemTemplate>
<asp:DropDownList ID="ddlDropDownList" runat="server" AutoPostBack="True"
onselectedindexchanged="ddlDropDownList_SelectedIndexChanged">
<asp:ListItem Text="0" Value="0" Selected="True"></asp:ListItem>
<asp:ListItem Text="1" Value="1"></asp:ListItem>
<asp:ListItem Text="2" Value="2"></asp:ListItem>
<asp:ListItem Text="3" Value="3"></asp:ListItem>
<asp:ListItem Text="4" Value="4"></asp:ListItem>
<asp:ListItem Text="5" Value="5"></asp:ListItem>
<asp:ListItem Text="6" Value="6"></asp:ListItem>
<asp:ListItem Text="7" Value="7"></asp:ListItem>
<asp:ListItem Text="8" Value="8"></asp:ListItem>
<asp:ListItem Text="9" Value="9"></asp:ListItem>
<asp:ListItem Text="10" Value="10"></asp:ListItem>
<asp:ListItem Text="11" Value="11"></asp:ListItem>
<asp:ListItem Text="12" Value="12"></asp:ListItem>
<asp:ListItem Text="13" Value="13"></asp:ListItem>
<asp:ListItem Text="14" Value="14"></asp:ListItem>
<asp:ListItem Text="15" Value="15"></asp:ListItem>
<asp:ListItem Text="16" Value="16"></asp:ListItem>
<asp:ListItem Text="17" Value="17"></asp:ListItem>
<asp:ListItem Text="18" Value="18"></asp:ListItem>
<asp:ListItem Text="19" Value="19"></asp:ListItem>
<asp:ListItem Text="20" Value="20"></asp:ListItem>
<asp:ListItem Text="21" Value="21"></asp:ListItem>
<asp:ListItem Text="22" Value="22"></asp:ListItem>
<asp:ListItem Text="23" Value="23"></asp:ListItem>
<asp:ListItem Text="24" Value="24"></asp:ListItem>
<asp:ListItem Text="25" Value="25"></asp:ListItem>
<asp:ListItem Text="26" Value="26"></asp:ListItem>
<asp:ListItem Text="27" Value="27"></asp:ListItem>
<asp:ListItem Text="28" Value="28"></asp:ListItem>
<asp:ListItem Text="29" Value="29"></asp:ListItem>
<asp:ListItem Text="30" Value="30"></asp:ListItem>
<asp:ListItem Text="33" Value="31"></asp:ListItem>
<asp:ListItem Text="33" Value="32"></asp:ListItem>
<asp:ListItem Text="33" Value="33"></asp:ListItem>
<asp:ListItem Text="34" Value="34"></asp:ListItem>
<asp:ListItem Text="35" Value="35"></asp:ListItem>
<asp:ListItem Text="36" Value="36"></asp:ListItem>
<asp:ListItem Text="37" Value="37"></asp:ListItem>
<asp:ListItem Text="38" Value="38"></asp:ListItem>
<asp:ListItem Text="39" Value="39"></asp:ListItem>
<asp:ListItem Text="40" Value="40"></asp:ListItem>
<asp:ListItem Text="44" Value="41"></asp:ListItem>
<asp:ListItem Text="44" Value="42"></asp:ListItem>
<asp:ListItem Text="44" Value="44"></asp:ListItem>
<asp:ListItem Text="44" Value="45"></asp:ListItem>
<asp:ListItem Text="45" Value="45"></asp:ListItem>
<asp:ListItem Text="46" Value="46"></asp:ListItem>
<asp:ListItem Text="47" Value="47"></asp:ListItem>
<asp:ListItem Text="48" Value="48"></asp:ListItem>
<asp:ListItem Text="49" Value="49"></asp:ListItem>
<asp:ListItem Text="50" Value="50"></asp:ListItem>
</asp:DropDownList>
<asp:Label runat="server" ID="lblOrderStatus"></asp:Label>
</ItemTemplate>
<ItemStyle Font-Bold="True" Font-Size="Medium" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Extended Price">
<ItemTemplate>
<asp:Label runat="server" ID="Totals"></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Label runat="server" ID="SubTotals"></asp:Label>
<asp:Label ID="lblTotal" runat="server"></asp:Label>
</FooterTemplate>
</asp:TemplateField>
</Columns>
<HeaderStyle
Font-Size="XX-Small" />
<AlternatingRowStyle Font-Size="XX-Small" />
</asp:GridView>
---this is the CodeBehind script I would like to convert---
Dim TotalUnitPrice As Decimal = 0.0
Protected Sub ddlDropDownList_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
Dim ddlCurrentDropDownList As DropDownList = CType(sender, DropDownList)
Dim grdrDropDownRow As GridViewRow = (CType(ddlCurrentDropDownList.Parent.Parent, GridViewRow))
Dim lblCurrentStatus As Label = CType(grdrDropDownRow.FindControl("lblOrderStatus"), Label)
If Not lblCurrentStatus Is Nothing Then
Dim ddlCurrent As DropDownList = sender
'try to get the rox index
Dim grdRow As GridViewRow = ddlCurrentDropDownList.Parent.Parent
Dim Row As GridViewRow = CType(CType(sender, Control).Parent.Parent, _
GridViewRow)
'end
Dim index As Integer = Row.RowIndex
Dim lbl As Label = Row.FindControl("Totals")
Dim txtPrice As Label = Row.FindControl("Price")
Dim lbQty As DropDownList = Row.FindControl("ddlDropDownList")
Dim qty As String = CInt(lbQty.SelectedValue)
Dim price As Double = CDbl(txtPrice.Text)
Dim lblTotal As Label = GridView1.FooterRow.FindControl("SubTotals")
lbl.Text = String.Format("{0:c}", (CType(qty, Decimal) * CType(price, Decimal)))
Dim PriceTotal As String = String.Format("{0:c}", (CType(qty, Decimal) * CType(price, Decimal)))
TotalUnitPrice = Session("SubTotal") + PriceTotal
Session("SubTotal") = TotalUnitPrice
lblTotal.Text = String.Format("{0:c}", Session("SubTotal"))
End If
End Sub
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.