5 Replies - 3968 Views - Last Post: 02 September 2010 - 06:15 AM Rate Topic: -----

#1 jagman82  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 24
  • Joined: 24-February 10

Mapping DropDownList with MySQL database

Posted 01 September 2010 - 06:28 AM

Hello everyone! I am stuck on something so I decided to come looking for it. I am needing to do, what I thought was simple, is taking a drop down list and textbox and with every change on the dropdownlist, it needs to be moved to a database. Any ideas? I am absolutely lost and not having much luck with the web.

Jagman
Is This A Good Question/Topic? 0
  • +

Replies To: Mapping DropDownList with MySQL database

#2 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1526
  • View blog
  • Posts: 5,961
  • Joined: 21-March 08

Re: Mapping DropDownList with MySQL database

Posted 01 September 2010 - 07:05 AM

So on the selection change of the DropDownList, what do you want to save to the database?
Was This Post Helpful? 0
  • +
  • -

#3 jagman82  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 24
  • Joined: 24-February 10

Re: Mapping DropDownList with MySQL database

Posted 01 September 2010 - 09:31 AM

I have 7 items in my drop down list, a text box and a MySQL database. I need to take the text that is written and send it to the database when another item is chosen from the drop down.

Jagman
Was This Post Helpful? 0
  • +
  • -

#4 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1526
  • View blog
  • Posts: 5,961
  • Joined: 21-March 08

Re: Mapping DropDownList with MySQL database

Posted 01 September 2010 - 10:05 AM

Ok...so which part are you having trouble with? Getting the text from the textbox? Doing it only when the selected index changes for the DropDownList? Connecting to MySQL?
Was This Post Helpful? 0
  • +
  • -

#5 jagman82  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 24
  • Joined: 24-February 10

Re: Mapping DropDownList with MySQL database

Posted 02 September 2010 - 06:04 AM

Pretty much the entire thing. I am wanting to use the SqlDataSource but that is not proving easy enough. I can move text to a database upon entering the INSERT statement. The main problem is that when my drop down choice changes, the text box needs to clear and make way for a new text entry for the MySQL database.

Jagman
Was This Post Helpful? 0
  • +
  • -

#6 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1526
  • View blog
  • Posts: 5,961
  • Joined: 21-March 08

Re: Mapping DropDownList with MySQL database

Posted 02 September 2010 - 06:15 AM

First you will need to download the MySQL connector for .Net(if you already haven't).

When the selection of a DropDownList is changed, it fires the SelectedIndexChanged event. You can subscribe to this event(using the Properties window in the designer).

private void dropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
     string userText = textBox1.Text;

     // this method would do your database operations
     SaveTextToDatabase(userText);

     textBox1.Text = string.Empty;
}



Make sure you set the AutoPostback property to True. It is defaulted to False. If you don't change this, the selection change of the DropDownList will not postback to the server.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1