paulwhelan
asked on
Starter website question
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_SelectedInde xChanged(o bject sender, EventArgs e)
{
if (DropDownList1.Text == "paulwhelan")
TextBox1.Text = "Male";
else
TextBox1.Text = "Female";
}
}
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.
using System.Web.UI.HtmlControls
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void DropDownList1_SelectedInde
{
if (DropDownList1.Text == "paulwhelan")
TextBox1.Text = "Male";
else
TextBox1.Text = "Female";
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Check the property (IsPostBack) of web page.
ASKER
thanks
just one more thing
should i use
DropDownList1.Text
or
DropDownList1.Value
Whats the difference?
Thanks
Paul
just one more thing
should i use
DropDownList1.Text
or
DropDownList1.Value
Whats the difference?
Thanks
Paul
the same thing
but i use this all time
DropDownList1.SelectedValu e.Equals(" paulwhelan ")
but i use this all time
DropDownList1.SelectedValu
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
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
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
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
ASKER
I see
DropDownList1.SelectedInde x
DropDownList1.SelectedItem
DropDownList1.SelectedValu e
Are they all different?
Thanks
Paul
DropDownList1.SelectedInde
DropDownList1.SelectedItem
DropDownList1.SelectedValu
Are they all different?
Thanks
Paul