473,396 Members | 2,020 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,396 software developers and data experts.

how to read data from dropdown list and save it into new database table

in my dropdown list, all company's name lists,and what i want is to save primary key of company only.Here my coding...

file.aspx
[<asp:DropDownList ID="dropselectProvider" runat="server" DataSourceID="selectProvider" DataTextField="name" DataValueField="providerID" Visible="False" AppendDataBoundItems="True" AutoPostBack="True">
<asp:ListItem>Select Provider/Organiser</asp:ListItem>
</asp:DropDownList>
<asp:SqlDataSource ID="selectProvider" runat="server" ConnectionString="<%$ ConnectionStrings:hrTraining %>" ProviderName="<%$ ConnectionStrings:hrTraining.ProviderName %>" SelectCommand="SELECT providerID, name FROM hrts.provider ORDER BY name"></asp:SqlDataSource>

here my code behind file.aspx.cs
protected void btnAddNewSubmit_Click(object sender, EventArgs e)
{ DropDownList myproviderID = (DropDownList)ddselectProvider.FindControl("provid erID");
OdbcConnection myconn = new OdbcConnection(ConfigurationManager.ConnectionStri ngs["hrTraining"].ConnectionStrings);
OdbcCommand cmd = new OdbcCommand("INSERT INTO training(providerID) VALUES (?)", myconn)
{ cmd.Parameters.Add("@providerID", OdbcType.Int).Value = Convert.ToInt32(myproviderID.Text);
}
myconn.Open();
cmd.ExecuteQuery();
}
Dec 10 '07 #1
2 1968
hope anyones can help me..i need ur help ASAP..
Dec 10 '07 #2
dip_developer
648 Expert 512MB
see this link....

Using Parameterized Queries in ASP.Net
Dec 10 '07 #3

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

Similar topics

4
by: Marc | last post by:
I've gotten everything up and running except for this -- I'd like to be able to have people have a dropdown list of cities in the US to use (or wherever) and not have to input them manually into a...
4
by: Belinda | last post by:
Hello All I need to read a SQL Server table into a Web Page and within the Web Page to permit my users to make changes to the records, delete or add new records and then save the entire contents...
1
by: SABmore | last post by:
I have the following code that populates 3 independent drop-down boxes with data from arrays. From there the user can select a value from a drop-down list, or input data into a text box. The user...
1
by: Ian Davies | last post by:
Hello In a php file I have a drop down list with index numbers in whos default value is feed into an sql query that filters records from my database and displays them in an html table. Trouble...
3
by: Nicolae Fieraru | last post by:
Hi All, I have a problem and I can't figure out how to solve it. My database has three tables: tblCustomers, with CustomerId and CustomerName tblProducts, with ProductId and ProductCode...
2
by: Crazy Cat | last post by:
I am using a data-bound combobox with dropdownstyle set to dropdownlist. Teh combobox is bound to a bindingsource which is in turn bound to a table in my database. The table has only 4 rows and I...
1
by: Jerome | last post by:
Hi, I'm using a FormView for data entry and it works fine so far. With one exception: I replaced one of the automatically generated textfields by a dropdown list and the value from that list...
8
by: Wingot | last post by:
Hey, I have a program I am trying to write using Visual C#, SQL Server 2005/2008, and Visual Studio 2008, and one part of it includes a Schema called Client. Inside this schema, three tables...
5
by: abhi3211 | last post by:
i am using java inside java script page. in that page i want to use two dropdown list. in first dropdown list i am getting data from ms-access database. in second dropdown list i want to get data...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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,...

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.