how can i add the data base item to the drop down list(default item)

asp.net , db Turkey
  • 12 years ago

    Hi friends,i have one task regarding drop down list.

    That is ,I have one registration form, in that i have one CITY drop down list,COUNTRY drop down list.I filled it and the city name ,country name should be loaded in the database.

    Now my requirement is,in update form the CITY name,COUNTRY name should come defaultly from database according to the user's registered CITY,COUNTRY name(in drop down list).

    please help me, i am new to .net

  • 12 years ago

    You can always keep track of the logged in user & find the user's city, country etc details by querying for the same from the database's user details table.

  • 12 years ago

    myconnection.open()

     mycommand=new sqlcommand( " select countryname from table1",myconnection)

    Myadapter=new dataadapter(mycommand)

    dim dataset1 as  new dataset

    myadapter.fill( dataset1)

    myconnection.close()

    comboCountry.datasource=dataset1.tables(0)

    combocountry.displaymember=" column name"   // countryname etc

     

     

    check this  format of code in ur form load

     

     

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Programs must be written for people to read, and only incidentally for machines to execute.”