i have 1 gridview , a dropdownlist inside a gridview and a commandfield of (edit, update and cancel)
my gidview looks like this
Edit Surname Initials ParkingBay
CommandField Me Y dropdownlistvalue
CommandField You m dropdownlistvalue
i have 2 sqldatasource. the other one is for gridview and the other one is for dropddownlist the value that is in the dropdownlist is from a diffrent table called parkingbay and the values that are in surname and initials are from the other table called employee and (Employee and parkingbay tables are linked together) so what do i do if i want to put the value tha i've selected in a dropdownlist in an employee table because in an employee table some employee their parking is null. i want when i click on edit command field and select a value from a dropdownlist that take the valule from parkingbay table to be able to update it in employee table where thr surname and initials are displayed.
my code is as follows
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="AllocateBay.aspx.vb" Inherits="_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">
<script type="text/javascript">function exit()
{
parent.window.close();
}
</script>
<title>Allocate Parking Bay</title> </head>
<body style="font-size: 9pt; font-family: Arial">
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView2" runat="server" AllowPaging="True" AutoGenerateColumns="False"
DataKeyNames="Bay" DataSourceID="SqlDataSource1" PageSize="3">
<Columns>
<asp:BoundField DataField="Bay" HeaderText="Unassigned Bay" ReadOnly="True" SortExpression="Bay" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NPI Employee MasterConnectionString81 %>"
SelectCommand="SELECT PB.Bay FROM ParkingBays AS PB LEFT OUTER JOIN Employee AS E ON E.ParkingBay = PB.Bay WHERE (E.NPI_EmployeeID IS NULL)">
</asp:SqlDataSource>
<br />
<strong>Allocate Parking Bay</strong></div>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
DataSourceID="SqlDataSource2" AutoGenerateColumns="False" Width="252px" style="width: 200px" AllowSorting="True">
<Columns>
<asp:CommandField HeaderText="Allocate" ShowEditButton="True" />
<asp:BoundField DataField="NPI_EmployeeID" HeaderText="NPI_EmployeeID" InsertVisible="False"
ReadOnly="True" SortExpression="NPI_EmployeeID" Visible="False" />
<asp:BoundField DataField="Surname" HeaderText="Surname" SortExpression="Surname" />
<asp:BoundField DataField="Initials" HeaderText="Initials" SortExpression="Initials" />
<asp:TemplateField>
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource1"
DataTextField="Bay" DataValueField="Bay" Width="70px" >
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NPI Employee MasterConnectionString81 %>"
SelectCommand="SELECT PB.Bay FROM ParkingBays AS PB LEFT OUTER JOIN Employee AS E ON E.ParkingBay = PB.Bay WHERE (E.NPI_EmployeeID IS NULL)">
</asp:SqlDataSource>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:NPI Employee MasterConnectionString28 %>"
SelectCommand="SELECT NPI_EmployeeID, Surname, Initials FROM Employee WHERE (ParkingBay IS NULL) AND (CurrentEmployee_YN = 1) ORDER BY Surname" UpdateCommand="UPDATE Employee SET ParkingBay = @parkingbay WHERE (NPI_EmployeeID = @NPI_EmployeeID)">
<UpdateParameters>
<asp:Parameter Name="parkingbay"/>
<asp:Parameter Name="NPI_EmployeeID" />
</UpdateParameters>
</asp:SqlDataSource>
<table style="font-weight: bold">
<tr>
<td class="tableContents" style="height: 18px">
<u><b>Notes :</b></u></td>
</tr>
<tr>
<td class="tableContents">
3 parkings used as storeroom<br />
underground.</td>
</tr>
</table>
<br />
<br />
<input id="Button1" onclick="exit()" style="width: 101px; background-color: #ff0066"
type="button" value="Close" /><br />
</form>
</body>
</html>