[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Starter website question

Posted on 2006-05-26
8
Medium Priority
?
555 Views
Last Modified: 2008-01-09
Hi
I created a page with a dropdownlist and a textbox.
I wanted to fill the textbox with some text depending on what is selected in the dropdownbox.

My code is below.

I double clicked on the dropdownbox and I thought this would work.

Thanks
Paul

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (DropDownList1.Text == "paulwhelan")
            TextBox1.Text = "Male";
        else
            TextBox1.Text = "Female";
    }
}


0
Comment
Question by:paulwhelan
  • 3
  • 3
  • 2
8 Comments
 

Accepted Solution

by:
newnewmommon earned 80 total points
ID: 16767457
in the properties windows for DropDownList1 u can see (AutoPostBack) this by default is false set = true

AutoPostBack=true

for more info see this
http://msdn.microsoft.com/library/default.asp?url=/workshop/webcontrols/webforms/library/shared/AutoPostBack.asp
0
 
LVL 6

Expert Comment

by:MuhammadAdil
ID: 16767832
Check the property (IsPostBack) of web page.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:paulwhelan
ID: 16767892
thanks

just one more thing

should i use

DropDownList1.Text
or
DropDownList1.Value

Whats the difference?

Thanks
Paul
0
 

Expert Comment

by:newnewmommon
ID: 16767959
the same thing

but i use this all time

DropDownList1.SelectedValue.Equals("paulwhelan")
0
 
LVL 6

Expert Comment

by:MuhammadAdil
ID: 16768078
if ur r binding drordownlist with datasource
there are different properties DisplayMember and ValueMember
u can assign these same field of two different fields
 such as
 myDropdown.datasource = ds.Customer (ds -- DataSet)
 myDropdown.DisplayMember = "CustomerName"
 myDropdown.ValueMember = "CustomerID"  for same  myDropdown.ValueMember = "CustomerName"

myDropdown.SelectedText will be Displaymember values
myDropdown.SelectedValue will be Valuemember values
 

Best regards
0
 

Expert Comment

by:newnewmommon
ID: 16768132
SelectedText  mean the value that the Client will see it
SelectedValue mean the value will use with this text

example if u have dropdownlist  with all country in the world and u select (United State)
SelectedText  =United State
SelectedValue =US

all developer use SelectedValue to save small value in the database
0
 

Author Comment

by:paulwhelan
ID: 16769341
I see

DropDownList1.SelectedIndex
DropDownList1.SelectedItem
DropDownList1.SelectedValue

Are they all different?

Thanks
Paul
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

868 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question