PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 5.00 average.

Re: Insert SQL data in table2 from dropdownlist table1

 
 
intrader
Guest
Posts: n/a
 
      27th Jul 2007
Peter wrote:
> Hi,
>
> I’m new to ASP.NET. (VB)
> I found a huge amount of examples of how to populate a dropdown box with
> data from table1. I found many examples to insert data in table2. But I can’t
> find any working example how to pick up a selection in dropdown box 1
> (table1) and insert it in table2.
>
> Thanks for the help.
> Regards,
> Peter
>
>
> <!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">
> </head>
> <body bgcolor="ivory">
> <form id="form1" runat="server"
> ACTION="bouwmanager_OP_2007.01.aspx?TaskNumber=3.2.&WebSitePart=Architect
> Toevoegen 2" method="get">
> <div>
>
> <asp:formview
> id="Meetstaat_Producten_Toevoegen_Form"
> datasourceid="Meetstaat_Producten_Toevoegen_DataSource"
> defaultmode="insert"
> runat="server" Width="480px" Font-Names="Verdana" Font-Size="Small"
> HorizontalAlign="NotSet" InsertRowStyle-HorizontalAlign="NotSet"
> RowStyle-HorizontalAlign="NotSet" BorderWidth="1" BorderColor="Blue"
> BorderStyle="Solid">
> <insertitemtemplate>
> <table>
> <tr>
> <td width="100"><asp:Label ID="meetstaatid"
> Text="MeetstaatID" AssociatedControlID="txt_meetstaatid" runat="server"
> Width="200px" /></td>
> <td width="200"><asp:TextBox id="txt_meetstaatid"
> text='<%# bind("meetstaatid") %>' runat="server" Width="250px"/></td>
> </tr>
> <tr>
> <td width="100"><asp:Label ID="level1groepid"
> Text="Level1GroepID" AssociatedControlID="txt_level1groepid" runat="server"
> Width="200px" /></td>
> <td width="200"><asp:TextBox id="txt_level1groepid"
> text='<%# bind("level1groepid") %>' runat="server" Width="250px"/></td>
> </tr>
> <tr>
> <td width="100"><asp:Label ID="level2groepid"
> Text="Level2GroepID" AssociatedControlID="txt_level2groepid" runat="server"
> Width="200px" /></td>
> <td width="200"><asp:TextBox id="txt_level2groepid"
> text='<%# bind("level2groepid") %>' runat="server" Width="250px"/></td>
> </tr>
> <tr>
> <td width="100"><asp:Label id="eenheidid"
> text="EenheidID" associatedcontrolid="eenheden" runat="server"
> Width="146px"/></td>
> <td width="200">
> <aspropDownList
> id="eenheden"
> DataSourceID="Eenheden_DataSource"
> DataTextField="omschrijving"
> DataValueField="id"
> runat="server" />
> <asp:sqldatasource
> id="Eenheden_DataSource"
> runat="server"
> selectcommand="select * from eenheden"
> connectionstring="<%$
> connectionstrings:BouwManager_2007.01ConnectionString1 %>"/>
> </td>
> </tr>
> <tr>
> <td width="100"><asp:Label id="prijs"
> text="prijs" associatedcontrolid="txt_prijs" runat="server"
> Width="150px"/></td>
> <td width="200"><asp:TextBox id="txt_prijs" text='<%#
> bind("prijs") %>' runat="server" Width="250px" style="position: static"
> Height="22px"/></td>
> </tr>
> <tr>
> <td width="100"><asp:Label id="aantal"
> text="Aantal" associatedcontrolid="txt_aantal" runat="server"
> Width="150px"/></td>
> <td width="200"><asp:TextBox id="txt_aantal" text='<%#
> bind("aantal") %>' runat="server" Width="250px" style="position: static"
> Height="22px"/></td>
> </tr>
> <tr>
> <td width="100"><asp:Label id="productfreetext"
> text="ProductFreeText" associatedcontrolid="txt_productfreetext"
> runat="server" Width="150px"/></td>
> <td width="200"><asp:TextBox id="txt_productfreetext"
> text='<%# bind("productfreetext") %>' runat="server" Width="250px"
> style="position: static" Height="22px"/></td>
> </tr>
> </table>
>
>
> <asp:Button
> id="submit"
> text="toevoegen"
> commandname="insert"
> runat="server" style="position: static" />
>
> </insertitemtemplate>
> </asp:formview>
>
>
>
> <asp:sqldatasource
> id="Meetstaat_Producten_Toevoegen_DataSource"
> runat="server"
> connectionstring="<%$
> connectionstrings:BouwManager_2007.01ConnectionString1 %>"
> insertcommand="insert into meetstaat_producten select
> meetstaatid=@meetstaatid,
> level1groepid=@level1groepid,level2groepid=@level2groepid,aantal=@aantal,prijs=@prijs,eenheidid=@s_eenheden,productfreetext=@productfreetext">
> <InsertParameters>
> <asp:ControlParameter
> ControlID="Meetstaat_Producten_Toevoegen_Form" Name="s_eenheden"
> PropertyName="id" />
> </InsertParameters>
> </asp:sqldatasource>
>
>
> </div>
>
> </form>
>
> </body>
> </html>
>
>

In the first DropDownList catch the OnSelectedIndexChanged event and
pick up the value using Eenheden_DataSource.SelectedIndex.Text (you can
also get the value). Then insert into the second DownDownList and set
the SelectedIndex to true.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL update of Table1 by data in Table2 in all fields at once Milan Wendl, aaaengineering.com Microsoft Access Queries 4 9th Jan 2009 06:04 AM
qty in table1 minus qty in table2 equal to result column in table2 =?Utf-8?B?aGlzaGFt?= Microsoft Access VBA Modules 2 15th Nov 2007 01:34 PM
if table1.field1 is empty, table2.field1, table1.field1 in form ricardozelaya via AccessMonster.com Microsoft Access 1 4th May 2006 04:08 PM
Insert Name record into TABLE2 if TABLE1 field is Yes. Joe M Microsoft Access Forms 2 1st Sep 2004 03:11 PM
How i can select table1 and insert into table2? Michael Microsoft C# .NET 4 6th Oct 2003 04:22 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:27 PM.