Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > DropDownList - pre-position to an entry

Reply
Thread Tools

DropDownList - pre-position to an entry

 
 
Larry
Guest
Posts: n/a
 
      01-17-2004
If I have a Dropdownlist box with several items in it, and I want to display that listbox to the browser with an entry already selected (which may not necessarily be the last item selected by the user), is there a method that does this?
 
Reply With Quote
 
 
 
 
Jeffrey Tan[MSFT]
Guest
Posts: n/a
 
      01-17-2004

Hi,

Thank you for using MSDN Newsgroup! My name is Jeffrey, and I will be
assisting you on this issue.
Based on my understanding, you have a Dropdownlist on your web form, when
user visit your web page, you want to set one of the item in your list to
be selected.
If I misunderstand you, please feel free to point me out.

=============================

Actually, I think you can use DropDownList.SelectedIndex to set the default
selected item's index. Do like this:

private void Button1_Click(object sender, System.EventArgs e)
{
DropDownList1.SelectedIndex=2;
}

Please apply my suggestion above and let me know if it helps resolve your
problem.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

 
Reply With Quote
 
 
 
 
Larry
Guest
Posts: n/a
 
      01-18-2004
That's all I needed. Thanks
 
Reply With Quote
 
Simon
Guest
Posts: n/a
 
      01-20-2004
Jeffrey,

I'm doing something similar, except I'm using ddl.SelectedValue. On Page_Load this works fine, but if I try the same code elsewhere on the form (ie: a Cancel button to reset the values) then the dropdownlist will always revert to the first element in the list.

Code:
MyDataSet.Merge((DataSet)Session["MyStoredDataSet"]);
MyDataView.RowFilter = "State = " + Session["StoredState"].ToString();
ddlState.DataBind(); // Where SelectedValue is databound to State in MyDataView.


On Page_Load, fine. Elsewhere, uh-uh.

Can you help?

Simon.


----- \"Jeffrey Tan[MSFT]\" wrote: -----


Hi,

Thank you for using MSDN Newsgroup! My name is Jeffrey, and I will be
assisting you on this issue.
Based on my understanding, you have a Dropdownlist on your web form, when
user visit your web page, you want to set one of the item in your list to
be selected.
If I misunderstand you, please feel free to point me out.

=============================

Actually, I think you can use DropDownList.SelectedIndex to set the default
selected item's index. Do like this:

private void Button1_Click(object sender, System.EventArgs e)
{
DropDownList1.SelectedIndex=2;
}

Please apply my suggestion above and let me know if it helps resolve your
problem.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


 
Reply With Quote
 
 
 
Reply

Thread Tools

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
if Dropdownlist Contains entry jobs ASP .Net 1 11-15-2007 09:55 PM
Allowing entry of a Carriage Return during data entry Mike Owen ASP .Net Web Controls 3 07-27-2006 02:34 PM
Form field entry directs to diff URLs based on entry? AtomicBob HTML 14 05-02-2006 07:07 AM
Form entry to Time part of database Date entry? Noozer Javascript 2 08-01-2005 08:10 PM
Dropdownlist -- user data entry et ASP .Net 1 05-21-2005 02:47 PM



Advertisments