apologies if this is in the wrong section,
the situation:
i have a drop down box with the values 1 - 10
<asp:DropDownList ID="DD" runat="server" Text='<%# Bind("DD") %>'>
<asp:ListItem Value="1"></asp:ListItem>
<asp:ListItem Value="2"></asp:ListItem>
<asp:ListItem Value="3"></asp:ListItem>
<asp:ListItem Value="4"></asp:ListItem>
<asp:ListItem Value="5" Selected="True"></asp:ListItem>
<asp:ListItem Value="6"></asp:ListItem>
<asp:ListItem Value="7"></asp:ListItem>
<asp:ListItem Value="8"></asp:ListItem>
<asp:ListItem Value="9"></asp:ListItem>
<asp:ListItem Value="10"></asp:ListItem>
</asp:DropDownList>
i have a database table with four columns (Hours, EmployeeID, Rate, PayTotal)
<asp:GridView ID="GridView2" runat="server" DataSourceID="SqlDataSource2"
EmptyDataText="no data record." Width="748px" AllowPaging="True"
AllowSorting="True" CellPadding="4" ForeColor="#333333" GridLines="Both"
AutoGenerateColumns="False">
<Columns>
<asp:BoundField DataField="Hours" HeaderText="Hours"
SortExpression="Hours" NullDisplayText="Null">
<ItemStyle BorderStyle="Dotted" />
</asp:BoundField>
<asp:BoundField DataField="EmployeeID" HeaderText="EmployeeID"
SortExpression="EmployeeID" />
<asp:BoundField DataField="Rate" HeaderText="Rate"
SortExpression="Rate" />
<asp:BoundField DataField="PayTotal" HeaderText="PayTotal"
SortExpression="PayTotal" ReadOnly="True" />
</Columns>
<RowStyle BackColor="#FFFBD6" ForeColor="#333333" HorizontalAlign="Center"/>
<FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:Ad_newConnectionString1 %>"
ProviderName="<%$ ConnectionStrings:Ad_newConnectionString1.ProviderName %>"
SelectCommand="SELECT EmployeeID, Rate, DropDownList.DD AS Hours, Hours * Rate AS PayTotal FROM HumanResources.EmployeePayHistory"/>
sorry about all of the code, thought it would be best to stick everything in, in-case any one picks up on my problem.
the user will select the amount of hours worked from the drop down list
on doing this i want it to insert that value in to the column "Hours" and then once it has done that multiple it by the rate to give the 'PayTotal'
i can multiply the columns no problems but cannot for the life of me work out why it wont populate 'Hours' with the value from the drop down list
any help would be very handy as i have hit a brick wall on this i have tried a few things i found on google search but they all seem over complicated and don't seem to work unless i have missed some thing major
my whole code!
<%@ Import Namespace = "System.Data" %>
<%@ Import Namespace = "System.Data.SqlClient" %>
<%@ Page Language="C#" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>pay multiply</title>
</head>
<body onclick="return window_onclick()">
<form id="form1" runat="server" title="welcome" onkeyup="return form1_onkeyup()">
<div>
<asp:TextBox ID="THours" runat="server" />
<asp:CheckBox ID="CheckBox1" runat="server"/>
<asp:Button ID="Button1" runat="server" Text="Button" />
<asp:DropDownList ID="DD" runat="server" Text='<%# Bind("DD") %>'>
<asp:ListItem Value="1"></asp:ListItem>
<asp:ListItem Value="2"></asp:ListItem>
<asp:ListItem Value="3"></asp:ListItem>
<asp:ListItem Value="4"></asp:ListItem>
<asp:ListItem Value="5" Selected="True"></asp:ListItem>
<asp:ListItem Value="6"></asp:ListItem>
<asp:ListItem Value="7"></asp:ListItem>
<asp:ListItem Value="8"></asp:ListItem>
<asp:ListItem Value="9"></asp:ListItem>
<asp:ListItem Value="10"></asp:ListItem>
</asp:DropDownList>
</div>
<div style="height: 371px; width: 746px;">
<asp:GridView ID="GridView2" runat="server" DataSourceID="SqlDataSource2"
EmptyDataText="no data record." Width="748px" AllowPaging="True"
AllowSorting="True" CellPadding="4" ForeColor="#333333" GridLines="Both"
AutoGenerateColumns="False">
<Columns>
<asp:BoundField DataField="Hours" HeaderText="Hours"
SortExpression="Hours" NullDisplayText="Null">
<ItemStyle BorderStyle="Dotted" />
</asp:BoundField>
<asp:BoundField DataField="EmployeeID" HeaderText="EmployeeID"
SortExpression="EmployeeID" />
<asp:BoundField DataField="Rate" HeaderText="Rate"
SortExpression="Rate" />
<asp:BoundField DataField="PayTotal" HeaderText="PayTotal"
SortExpression="PayTotal" ReadOnly="True" />
</Columns>
<RowStyle BackColor="#FFFBD6" ForeColor="#333333" HorizontalAlign="Center"/>
<FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:Ad_newConnectionString1 %>"
ProviderName="<%$ ConnectionStrings:Ad_newConnectionString1.ProviderName %>"
SelectCommand="SELECT EmployeeID, Rate, DropDownList.DD AS Hours, Hours * Rate AS PayTotal FROM HumanResources.EmployeePayHistory"/>
<br />
</div>
</form>
</body>
</html>