| | |
drop down list question.
Please support our ASP.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
![]() |
•
•
Join Date: Sep 2007
Posts: 7
Reputation:
Solved Threads: 0
Using Visual Web Developer, I am wanting to use a Drop-Down list on a Web Form. I know how to use HTML to create and add items to a Drop-Down list. The problem is that I need to populate the list from a database. So I used a DropDownList control from the menu. I specify where the database is and which table and columns to use. The problem I am running into, and not seeing any fix for, is that I need to be able to select an item and automatically be linked to another page. I set a table in my DB to be a hyperlink field, but that does not seem to work. I set the AutoPost to true, but all that seems to do is refresh the page. I am guessing that it is trying to place data on the same page, but that is not what I need.
So basically, all I need is a Drop Down that gets populated from a DB, and when a item is selected in the Drop Down it links to another page. Sounds easy, huh?
I need someone who is smarter than me. Can this even be done? Please help. Thank you.
So basically, all I need is a Drop Down that gets populated from a DB, and when a item is selected in the Drop Down it links to another page. Sounds easy, huh?
I need someone who is smarter than me. Can this even be done? Please help. Thank you.
Using the AutoPostBack, check the value of the drop down box. Something like this:
Or, if you use VB:
c# Syntax (Toggle Plain Text)
protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack) { if (DropDownList1.SelectedValue == "foo") Response.Redirect("somepage.aspx"); } }
VB Syntax (Toggle Plain Text)
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Page.IsPostBack Then If DropDownList1.SelectedValue = "foo" Then Response.Redirect("somepage.aspx") End If End If End Sub
foo is a value to compare against. You'll want to replace it with whatever value you have, and other values with else if statements. And I'm totally out of the habit of writing code. Those should be DropDownList.SelectedValue.Equals("foo") rather than using == and =
Last edited by Infarction; Sep 19th, 2007 at 12:02 am.
![]() |
Similar Threads
- Populate One Drop Down List From Another (ASP.NET)
- Populating a Drop-down List (PHP)
- generate drop down list..checkboxes...listbox... (ASP.NET)
- view employee info for the employee selected from the drop down list (PHP)
- Data Binding to a Drop Down List? (ASP.NET)
- Passing a drop down list item's value (HTML and CSS)
- Blank drop list (PHP)
Other Threads in the ASP.NET Forum
- Previous Thread: Printing of Data not window on Client Sde
- Next Thread: Edit item event handler issue
| Thread Tools | Search this Thread |
.net 2.0 3.5 activexcontrol advice ajax alltypeofvideos asp asp.net bc30451 beginner bottomasp.net browser businesslogiclayer c# c#gridviewcolumn cac checkbox class commonfunctions compatible confirmationcodegeneration content contenttype countryselector courier dataaccesslayer database datagrid datagridview datagridviewcheckbox datalist development dgv dropdownlist dropdownmenu dynamically edit fileuploader fill flash flv formatdecimal forms formview gridview gudi homeedition iframe iis javascript jquery listbox menu microsoft mouse mssql multistepregistration nameisnotdeclared news objects opera panelmasterpagebuttoncontrols problem redirect registration relationaldatabases reportemail rotatepage schoolproject security serializesmo.table sessionvariables silverlight smartcard smoobjects software sql sql-server sqlserver2005 textbox tracking treeview unauthorized validatedate validation vb.net video videos virtualdirectory vista visual-studio visualstudio web webapplications webarchitecture webdevelopemnt webprogramming webservice youareanotmemberofthedebuggerusers






