Print Page | Close Window

Bind Dropdown default

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: ASP.NET Discussion
Forum Description: Discussion and chat on ASP.NET related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=7538
Printed Date: 28 March 2026 at 4:07am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Bind Dropdown default
Posted By: michael
Subject: Bind Dropdown default
Date Posted: 23 November 2003 at 8:26pm
I am using the following code to bind an xml file to a dropdown:

ds.ReadXml(MapPath("collations.xml"))

ddlCollation.Visible = True

ddlCollation.DataSource = ds

ddlCollation.DataTextField = ds.Tables("Collations").Columns("ColDescription").ToString

ddlCollation.DataValueField = ds.Tables("Collations").Columns("Collation").ToString

ddlCollation.DataBind()


Fine and well, but how can I add the selected value, I have one specific that I want to be selected by default, I know I can just copy it to the top of the xml file but curious if there is a programatical way to do it.



-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker



Replies:
Posted By: MorningZ
Date Posted: 24 November 2003 at 6:24am
ddlCollation.Items.FindByValue(String Value of Item You Want Selected Here).Selected = True

-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: michael
Date Posted: 24 November 2003 at 9:43am
Aah, thanks a lot.

-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net