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

  • Home
  • SEARCH
  • 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 1033881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:18:02+00:00 2026-05-16T14:18:02+00:00

I have a drop down list that is populated in the page load event

  • 0

I have a drop down list that is populated in the page load event from a database table.

The drop down has a DataTextField set to a project name and the DataValueField set to the project id (interger).

Later I change the dropdowlist selected item with this code in the selectedindexchanged event of a gridview

GridViewRow row = GridView1.SelectedRow;
ddlProjectList.SelectedItem.Text = row.Cells[2].Text;

Does Changing the drop down list with this code cause the DataValueField property to change to the correct Project ID number also? If not is there a better way to do this?

=============================================EDIT
actually this code seems to be adding an additional item to the list so that the project i set with this code is listed twice so I don’t think my code is correct

  • 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-16T14:18:03+00:00Added an answer on May 16, 2026 at 2:18 pm

    This does not change anything else than the text of the selected item in your DropDownList. Do you want to change the text and value of the project, or do you want to select the project from the DropDownList that relates to the selected row in the grid?

    To change the project name and id, you’ll have to change it in the data source behind the ProjectList. But if you just want to select the related project, you can use this:

    var row = GridView1.SelectedRow;
    
    if (ProjectList.Items.FindByText(row.Cells[2].Text) != null)
    {
        ProjectList.ClearSelection();
        ProjectList.Items.FindByText(row.Cells[2].Text).Selected = true;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a drop-down list with known values. What I'm trying to do is
Suppose I have a drop-down list like: <select id='list'> <option value='1'>Option A</option> <option value='2'>Option
Does anyone know how many options a drop down list can have? Is it
I'd like to add a drop-down list to a Windows application. It will have
I have a DropDownList on an ASP.NET page that gets populated by a SQL
I have a dropdown list that stores name/value pairs. The dropdown appears in each
I have a CompositeControl that contains a DropDownList. I have set the AutoPostBack property
I have an asp page (Default.aspx) that displays the diff between two text files.
If I have a DropDownList control that makes up part of a CompositeControl how
I have the following code that sets a cookie: string locale = ((DropDownList)this.LoginUser.FindControl(locale)).SelectedValue; HttpCookie

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.