473,404 Members | 2,195 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

updating database using dropdownlist inside a gridview

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 />

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;

<input id="Button1" onclick="exit()" style="width: 101px; background-color: #ff0066"

type="button" value="Close" /><br />

&nbsp;





</form>





</body>
</html>
Sep 14 '07 #1
0 2196

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: | last post by:
Hello, I have created an ASP.NET 2.0 application that utilized a Gridview Control to display and update/delete data. The problem I am having is that the gridview control is displaying the data...
6
by: Dabbler | last post by:
I have a GridView with a couple of TemplateFields. When I click the update link the Gridview returns to display mode with no errors but the data from bound text fields or dropdown list isn't...
0
by: Mike P | last post by:
I want to update my gridview, but rather than specifying the Update Parameters etc in the GridView, I want to use my own code similar to the way I updated the DataGrid v1.1. I also want to make a...
4
by: =?Utf-8?B?QmFyYmFyYSBBbGRlcnRvbg==?= | last post by:
I setup a simple gridview as a utility just to do some updates, nothing fancy just wanted easy UI to make updates. When I select ‘Edit’, I get the fields I want to edit. I edit them and click...
1
by: Anilsg | last post by:
Hi all, I have the DropDownList in the FormView,inside InsertTemplateField The data is binded in run time to it in codebehind page,FOr the First time the page is loaded the DropdownList is...
0
by: Anilsg | last post by:
Hi all, I have the DropDownList in the FormView,inside InsertTemplateField The data is binded in run time to it in codebehind page,FOr the First time the page is loaded the DropdownList...
0
by: TheDebbis | last post by:
I'm making a quick CD catalog to help me learn ASP.NET (using C# primarily.) I have a number of gridview's on my site that are working properly, but for some reason, one is not updating or deleting....
0
by: baburk | last post by:
I am having dropdownlist inside gridview. When the dropdownlist selectedindex change an event should fire. What is the event for his. I also want to get the dropdownlist event fired row...
2
by: xMetalDetectorx | last post by:
Hi Everyone, I have a very simple web app that uses .Net 2.0 login control to authenticate users and allow access to an "admin" folder. Inside that admin folder I have one page that has a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.