Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 2nd, 2006, 12:18 PM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default Can't get the selected value of a combo...

hi all...

i have a dropdownlist inside a page, i fill it in this way:

Code:
        Dim Db As New OleDb.OleDbConnection
        If Not OpenDatabase(Db) Then
            Response.Redirect("Errores.aspx", True)
        End If
        Dim DbCom As New OleDb.OleDbCommand
        DbCom.CommandText = "Select * FROM dependencias"
        DbCom.Connection = Db
        Dim DbRead As OleDb.OleDbDataReader = DbCom.ExecuteReader
        DdlDependencias.DataSource = DbRead
        DdlDependencias.DataTextField = "Nombre"
        DdlDependencias.DataValueField = "Codigo"
        DdlDependencias.DataBind()
this code is in the page load.

after that i have and execute buttom to get the new value and redirect to a new page, but the combo always return the first value.. (not the select one, the first loaded in the combo).
anyone knows what im doing wrong??

thanks in advance...

also, how can i keep the data inside the combo between postbacks?? (so i dont have to fill it everytime the user make a selection??)

HTH

Gonzalo
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
  #2 (permalink)  
Old March 2nd, 2006, 03:15 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Wrap your code in an IF IsNotIsPostBack:

If Not IsPostBack Then
        Dim Db As New OleDb.OleDbConnection
        If Not OpenDatabase(Db) Then
            Response.Redirect("Errores.aspx", True)
        End If
        Dim DbCom As New OleDb.OleDbCommand
        DbCom.CommandText = "Select * FROM dependencias"
        DbCom.Connection = Db
        Dim DbRead As OleDb.OleDbDataReader = DbCom.ExecuteReader
        DdlDependencias.DataSource = DbRead
        DdlDependencias.DataTextField = "Nombre"
        DdlDependencias.DataValueField = "Codigo"
        DdlDependencias.DataBind()
End If

Jim


  #3 (permalink)  
Old March 2nd, 2006, 03:58 PM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

thanks for the help.. now if i do that then the combo (DdlDependencias) has no reference to the selecteditem in the buttom_click event (looks like the combo was unload before the click event??).. i had that in one version but them i take it off.. what im trying to do and no accomplish is to have a combo to populate a grid after the user make any selection, maybe you have an example i could try??

thanks again...

HTH

Gonzalo
  #4 (permalink)  
Old March 2nd, 2006, 04:48 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

do you want to have the user selecct an item in the ddl then use that value as a parameter to fill a datagrid?

If so, use the selecedindexchanged event of the ddl.

  #5 (permalink)  
Old March 3rd, 2006, 10:31 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

thank's for the help.

i try it without postback (nothing happend) and with postback (nothing happend either)...

could it be because i have the webform that inherits from another web form (take it from the msdn to make webforms with frames, but the code works ok (or at least for the rest of the things).

any other idea i can try?? i can paste all the code here but i dont think it will help. maybe the frames prevent the indexchange event to run???

HTH

Gonzalo
  #6 (permalink)  
Old March 3rd, 2006, 10:58 AM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

it could be because of the inheritance and the frames.. I can only guess since I don't have all the code and pages. Keep digging.. I am sure you will figure it out


  #7 (permalink)  
Old March 3rd, 2006, 12:09 PM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

yep yep.. the problems are the frames or the inheritance.. try it in a clean project and work perfect.. i will change my app to a normal one.. thanks for the help..



HTH

Gonzalo
  #8 (permalink)  
Old March 3rd, 2006, 02:48 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Glad to help :)

Jim

 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Combo box to display items from parent combo box Gini Visual Studio 2008 0 June 18th, 2008 12:30 AM
Combo box choice creating filtered combo box stevensj5 Access 11 September 13th, 2007 11:33 AM
combo box remain selected after submission RanjanD1 Classic ASP Professional 2 September 7th, 2007 07:56 AM
How to Update Selected Item in Combo after Postbac ZArrinPour ASP.NET 1.0 and 1.1 Basics 2 February 21st, 2006 02:17 AM
syntax error on <option selected="selected"> hamid HTML Code Clinic 1 October 13th, 2004 09:20 AM



All times are GMT -4. The time now is 05:14 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.