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

How to assign a textbox value in dropdownlistbox

14
I want to assign a textbox value to dropdownlistbox,where it should be updated in my database... Can u please give me some suggestions?

In textbox the date is assigned. In dropdownlistbox one user name is assigned. I have to set the particular date to one particular user..
Mar 30 '10 #1

✓ answered by Frinavale

Use the DropDownListBox.SelectedValue property to retrieve the value that the user selected.

Use the TextBox.Text property to retrieve the value that the user entered into the text box.

Once you've retrieved the values you can update your database.

9 5704
Frinavale
9,735 Expert Mod 8TB
Hi Yookify,

You're asking a little bit too much.
I'm not sure what you want to do actually....you have a TextBox and a DropDownList.

Now where I'm confused is....does the user enter Text into the TextBox and you want to use that to update the DropDownList....

Or do you want to set the Text in the TextBox with what the user selected in the DropDownList?

How does any of this tie into your database?
When are you supposed to update the database?

When the user selects an item in the DropDownList? When the user clicks a button????


Could you please clarify what you're trying to do...and in the mean time check out these articles:
-Frinny
Mar 30 '10 #2
Frinavale
9,735 Expert Mod 8TB
Please reply in thread.
Solving problems over PMs breaks the rules here.

thank u so much for ur reply

sorry if i asked too much..
i displayed date in textbox.that date should be assigned to a person in dropdown listbox.dropdown listbox used to have the name of the person from my database.i done the work with the date and dropdownlistbox,date and dropdownlistbox is well working.can u please tell me how to assign the particular date to a particular person in droplistbox.i used date using calendar.
When the user clicks the button to do the update you need to grab the selected value in the DropDownList and grab the date value from the TextBox.

Once you have these values you can update the database (follow the articles that I previously posted for details on how to do that).

-Frinny
Mar 30 '10 #3
yookify
14
thanks a lot for ur reply...
sorry i cant get ur ans..can u please be specify...i cant c any msg regarding my ques in net.can u please tell me.how to call that value in dropdownlistbox.for ex:dropdownlistbox1.selecteditem.To select an name what i have to specify?
Mar 31 '10 #4
Frinavale
9,735 Expert Mod 8TB
Use the DropDownListBox.SelectedValue property to retrieve the value that the user selected.

Use the TextBox.Text property to retrieve the value that the user entered into the text box.

Once you've retrieved the values you can update your database.
Mar 31 '10 #5
yookify
14
Thank for ur kind reply...But this i have done already.i think u didt get my query,if u dnt mine i will repeat it.textbox and dropdownlistbox is working well.textbox contain date from calendar and dropdownlistbox contains name of the person from my database.what i want to do is,


i want to update this date to a particular person for that what query i have to write .please reply me....

database
sno username password date
1 a aa NULL
2 b bb NULL
3 c cc NULL
4 d dd NULL
NULL NULL NULL NULL



Username is the person name(a,b,c,d) displayed on the dropdownlistbox and date is blank here i have to update date.i tried a lot but not coming..please can u help me

this the coding to display the username in dropdownlistbox:

myda = New SqlDataAdapter("Select * from sample ", connection)
ds = New DataSet
myda.Fill(ds, "sample")
DropDownList1.DataSource = ds
DropDownList1.DataTextField = ds.Tables(0).Columns("Username").ColumnName.ToStri ng()
DropDownList1.DataBind()




i want to know how to connect this date to dropdownlistbox.can u please tell me
Mar 31 '10 #6
Frinavale
9,735 Expert Mod 8TB
I think I understand your problem now....

You have to update the object that you are using as the data source for the DropDownListBox with the date selected for the person.

In your case, you are populating the data source (which is a DataSet) from your database.

This means that in order to update your DropDownListBox you either have to update your database with the value entered...which will result in your DropDownListBox being update since it is retrieving the data from the database.

Or, if you have cached the data set so that you don't need to make a call to the database between postbacks, you can update the Table within the DataSet that contains the data that you are using for the DropDownListBox.

-Frinny
Mar 31 '10 #7
yookify
14
Thanks My Problem is Solved
Apr 2 '10 #8
yookify
14
sorry again problem.please tell me
I want to update the date and names to a particular user.i dnt know what is the property to use (listbox) multipleselection and that multiple selections should be updated .

i used
mycmd.CommandText = "Update sample Set DATE ='" & ListBox1.Text & "' where USERNAME='" & DropDownList1.SelectedValue & "' "

Its working well.that .date is updated into a particular person

now how to use listbox
mycmd.CommandText = "Update sample Set DATE ='" & ListBox1.Text & "' and NAME ='"& listbox1.selectedvalue &"' where USERNAME='" & DropDownList1.SelectedValue & "' "

Error its telling that near and wrong keyword


I just used only listbox not date now
mycmd.CommandText = "Update sample Set NAME ='" & listbox1.SelectedValue & "'' where USERNAME='" & DropDownList1.SelectedValue & "' "

it is updating only one selected name from the list.i want to update more than one name to Username


database:

sno username password date name
1 a aa 12/3/09
2 b bb 13/3/09
3 c cc 12/4/09
4 d dd 4/3/10
NULL NULL NULL NULL


in this using listbox i want to update a list of name for a particular username

Can u please help me .how to proceed further
Apr 2 '10 #9
Frinavale
9,735 Expert Mod 8TB
You should not be creating your SQL statement based on user input directly. You will run into problems (like the one your having now) and you are creating a security hole in your application that opens you up to Sql Injection Attacks.

You should be using parameters to supply user provided data in your SQL statements instead.

Look over the first database tutorial that I linked you to earlier for examples of how to create SQL commands using parameters to supply the user provided data....or check out the MSDN article on the SqlCommand.Parameters Property for more information and additional examples.

-Frinny
Apr 5 '10 #10

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

Similar topics

2
by: dskillingstad | last post by:
I'm trying to assign a custom value to a textbox. Here's what I have. I've created a module and "default value" code for a textbox which generates a custom auto-number (yyyy-0000) when a New...
2
by: Grey | last post by:
I want to assign a value to HMTL textbox with id "txtABC" in ASP.NET with C#
1
by: Shilpi Chaudhry | last post by:
I have a forloop which I use to create textboxes - but unfortunately all of them have the same ids - I need to assign different ids to these textboxes creeated in the loop so that I can retrieve...
1
by: pari kanaga | last post by:
I have server control dropdownlistbox populated with data from table. I don't know how to make this dropdownlistbox searchable. ( for example if i click the dropdownlistbox and type the name it...
8
by: Sergei | last post by:
Hi, I am displaying modal dialog and passing values from the main form to the modal dialog and back. It works fine but if I used the following syntax on Page_Load(just for testing) in VB to...
6
by: david | last post by:
I try to use "for" loop to retrieve and assign values in web form. The code is in the following. But it can not be compiled. What I want to do is: txtQ1.Text =...
1
by: Ted | last post by:
Here is a stored procedure I created in MySQL: CREATE PROCEDURE `sp_find_food`( IN search_string varchar(255) ) BEGIN DECLARE ss VARCHAR(257); SET ss = CONCAT('%',search_string,'%'); SELECT...
1
by: jeyapriya | last post by:
Dear Friends This is Jeyapriya. Right now I am working in the ASP.NET with VB coding & the back end is SQL SERVER 2000. My dilemma is I have to design a form with 2 DropDownListboxes. I have...
5
by: lianping | last post by:
Hi, I have a problem to assign a value into text box, below will be my script. Before view my script, let me hv quick explain on what is my problem: I would like to assign Java script value...
0
by: mesut | last post by:
Hi colleagues, I've a very strange problem here. I have no clue whyt it happens. I have a listview. The Listview populates well. I have an Update Button in the listview and a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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
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.