mike55 Posted September 20, 2005 Posted September 20, 2005 Hi all, Have filled a dropdown list with data directly from the database. Wish to have a specific value selected when the page first loads. I am using the following line of code: ddlOrgtype.DataSource = dsOrgTypes ddlOrgtype.DataTextField = "OrgType" ddlOrgtype.DataValueField = "Identifier" ddlOrgtype.DataBind() ddlOrgtype.selectedValue = "Select Organisation Type" I am getting the error: "Specificed arguement was out of range of valid values.", any suggestions on how to overcome this problem? Mike55 Quote A Client refers to the person who incurs the development cost. A Customer refers to the person that pays to use the product. ------ My software never has bugs. It just develops random features. (Mosabama vbforums.com)
mark007 Posted September 20, 2005 Posted September 20, 2005 Make sure "Select Organisation Type" is a possible value. Quote Please check the Knowledge Base before you post. "Computers are useless. They can only give you answers." - Pablo Picasso The Code Net
mike55 Posted September 21, 2005 Author Posted September 21, 2005 Make sure "Select Organisation Type" is a possible value. Yep, its a value that exists in the drop down. Got around the problem by using the following code: Me.ddlOrgtype.Items(6).Selected() = True Possible not the best way to do it, but still it works Mike55 Quote A Client refers to the person who incurs the development cost. A Customer refers to the person that pays to use the product. ------ My software never has bugs. It just develops random features. (Mosabama vbforums.com)
mark007 Posted September 21, 2005 Posted September 21, 2005 Are you sure it was a value and not just the displayed text? Quote Please check the Knowledge Base before you post. "Computers are useless. They can only give you answers." - Pablo Picasso The Code Net
JTDPublix Posted September 21, 2005 Posted September 21, 2005 Are you sure it was a value and not just the displayed text? You can't set selected "value" by specifying a text value. If you wanted to set it by a text value you'd need to use this: ddl.SelectedItem.Text = "Select Organisation Type" Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.