Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8528811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:53:10+00:00 2026-06-11T08:53:10+00:00

I have this code on an aspx page. <asp:DropDownList runat=server ID=ddlSize CssClass=textbox Width=100px> <asp:ListItem

  • 0

I have this code on an aspx page.

<asp:DropDownList runat="server" ID="ddlSize" CssClass="textbox" Width="100px">
<asp:ListItem Value="" Text="" />
<asp:ListItem Value="11" Text="11. Mands" />
<asp:ListItem Value="7" Text="7. Mands" />
<asp:ListItem Value="" Text="Ikke Kamp"/>
</asp:DropDownList>


 <asp:DropDownList runat="server" ID="ddlType" CssClass="textbox" Width="100px">
 <asp:ListItem Value="" Text="" />
 <asp:ListItem Value="K" Text="Kamp" />
 <asp:ListItem Value="T" Text="Træning" />
 <asp:ListItem Value="E" Text="Aktivitet"/>
 </asp:DropDownList>

ts inside a loginview with some other fields (textbox)
Im trying to get a record id into the page so i can edit it, I have fix it with the Textbox and its working 100%, but i cant get the value from the database into the dropdownlist so it show that value as selected.
I have tryed these 3 codes, but nothing is working fore the dropdownlist.

// DataValueField               
Dim drop_obj As DropDownList = TryCast(LoginView2.FindControl("ddlSize"), DropDownList)
drop_obj.DataValueField = dtEvents.Rows(0)("EventEventSize")

Dim drop_obj2 As DropDownList = TryCast(LoginView2.FindControl("ddlType"), DropDownList)
drop_obj2.DataValueField = dtEvents.Rows(0)("EventType")

// SelectedIndex
Dim drop_obj As DropDownList = TryCast(LoginView2.FindControl("ddlSize"), DropDownList)
drop_obj.SelectedIndex = dtEvents.Rows(0)("EventEventSize")

Dim drop_obj2 As DropDownList = TryCast(LoginView2.FindControl("ddlType"), DropDownList)
drop_obj2.SelectedIndex = dtEvents.Rows(0)("EventType")

// SelectedValue
Dim drop_obj As DropDownList = TryCast(LoginView2.FindControl("ddlSize"), DropDownList)
drop_obj.SelectedValue = dtEvents.Rows(0)("EventEventSize")

Dim drop_obj2 As DropDownList = TryCast(LoginView2.FindControl("ddlType"), DropDownList)
drop_obj2.SelectedValue = dtEvents.Rows(0)("EventType")

Can someone plz. help !? I have values in the 2 dtEvents.Rows(0) i have checked that, with a debug and then step-into.
and i get values like 7 or 11 and T or K.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T08:53:11+00:00Added an answer on June 11, 2026 at 8:53 am

    I think you’re trying to datebind your table to your list.

    You want to utilize these two properties:

    DataTextField
    DataValueField
    

    So, you want to set your DataTextField (what the user will see) to the column taht contains the display text and then you want to set your DataValueField (the value of the item that won’t be seen) to the column containing that. Then you want to call DataBind().

    For example (my VB is very rusty):

    Dim myDDL AS DropDownList();
    
    myDDL.DataTextField = myTable("ColumnDataUserSees")
    myDDL.DataValueField = myTable("ColumnDataIWillUse")
    myDDL.DataBind()
    

    Definitely check that syntax. I’ve been using C# for months and no VB, so that’s probably not 100%.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code in my aspx page: <form id=form2 runat=server> <asp:ScriptManager ID=ItemsScriptManager runat=server
I have an asp.net dropdown like this <asp:DropDownList width=95% ID=RessourceComposantes runat=server DataSourceID=Composantes DataTextField=Description DataValueField=ComposanteID>
I have the following drop down list: <asp:DropDownList runat=server ID=ddlShipping CssClass=shippingMenu AutoPostBack=true> <asp:ListItem Text=3-5
I have one <asp:Image ID=imgBanner1 runat=server/> control in my aspx page, then in code
I have a aspx Page where I am using AJAX. like <asp:UpdatePanel runat=server ID=upPanelDDLProgram>
Hello i have a aspx page and have this code on it: <asp:Button ID=ButtonOk
I have a standard button in my default.aspx page. <asp:Button ID=Search_Button runat=server Text=Search onclick=Search_Button_Click
I am using ASP.NET and in my .aspx page I have the following code,
I have this code in my ASP page: <%@ Register TagPrefix=genies Namespace=TheNamespace Assembly=TheAssembly%> ...
I have server side controls like textbox, dropdownlsit etc on aspx page and my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.