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 250699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:31:59+00:00 2026-05-11T21:31:59+00:00

I have a listview. In my listview I have a dropdownbox which I want

  • 0

I have a listview. In my listview I have a dropdownbox which I want to fill in my codebehind page. Only the thing is, I don’t know how to access this webcontrol. The following doesn’t work:

DropDownList ddl = (DropDownList)lvUserOverview.Controls[0];

I know the index is 0 because the dropdownlist is the only control on the listview (also when I try index 1 I get a index out of range exception).

Can someone tell me how i can access the dropdownlist? In my pagebehind I want to add listitems.

ASPX Code :

<asp:DropDownList ID="ddlRole" onload="ddlRole_Load" runat="server">
</asp:DropDownList>

Codebehind:

protected void ddlRole_Load(object sender, EventArgs e)
{
  DropDownList ddl = (DropDownList)lvUserOverview.FindControl("ddlRole");
  if (ddl != null)
  {
      foreach (Role role in roles)
          ddl.Items.Add(new ListItem(role.Description, role.Id.ToString()));
  }
}
  • 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-05-11T21:31:59+00:00Added an answer on May 11, 2026 at 9:31 pm

    To get a handle to the drop down list inside of its own Load event handler, all you need to do is cast sender as a DropDownList.

    DropDownList ddlRole = sender as DropDownList;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an activity which have ListView. When I want to access this ListView
I have a ListView control and I have added a DataBound event (don't know
I have listview which has 5000 items. I want to get item of listview
I have ListView with custom Adapter which supplies View to ListView in this way:
I have ListView in my project which has ListItems as in the form of
I have ListView which is saving all data to database. For adding i have
I have a ListView with Horizontal WrapPanel as its ItemsPanelTemplate. I want to get
I have ListVIew that is filled with hard-coded DataModel . Then I want to
I have listview and I want to have show new window when someone double
I have listview with 2 textbox and 1 checkbox on each row. I want

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.