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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:50:38+00:00 2026-06-11T16:50:38+00:00

I am trying to bind(select) the some data by value from my list but

  • 0

enter image description here

I am trying to bind(select) the some data by value from my list but it is not possible.

As you can see I store them by this value:

DataValueField=”ID_PROJECT_TYPE_DETAILS”

I have the following html code:

<asp:ListBox SelectionMode="Multiple" ID="DDLProjectDetails" runat="server" 
                        DataSourceID="SqlDataSource4" DataTextField="DESCRIPTION" 
                        DataValueField="ID_PROJECT_TYPE_DETAILS">
                                    </asp:ListBox>

                    <script type="text/javascript">
                        $(document).ready(function () {
                            $('#<%= DDLProjectDetails.ClientID %>').dropdownchecklist({ width: 248 });
                        });
                    </script>

                    <asp:SqlDataSource ID="SqlDataSource4" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:MesarchConnectionString %>" 
                        SelectCommand="SELECT * FROM [PROJECT_TYPE_DETAILS]"></asp:SqlDataSource>

and the code behind code:

string insCmd = "SELECT ID_PROJECT, ID_PROJECT_TYPE_DETAILS FROM PROJECT_TYPE_DETAILS_OF_PROJECT WHERE ID_PROJECT = @IDProject";

…

 dr = com.ExecuteReader();
            while (dr.Read())
            {
                if (DDLProjectDetails.Items.Contains(DDLProjectDetails.Items.FindByValue(dr.GetInt32(1).ToString()))) 
                    DDLProjectDetails.Items.FindByValue(dr.GetInt32(1).ToString()).Selected = true;
            }

and doesn’t fills my dropdownchecklist like this:
enter image description here

When I run the program my DDLProjectDetails doesn’t shows that has any items…

  • 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-11T16:50:39+00:00Added an answer on June 11, 2026 at 4:50 pm

    Items collection of DDLProjectDetails did not get data bound yet. All you have to do is call DataBind() so that when your code comes to ExecuteReader() ... Items are already bound.

    // demo code for one of my tables
    string conStr = YOUR_CON_STR;
    using (SqlConnection con = new SqlConnection(conStr))
    {
        SqlCommand com = new SqlCommand("SELECT [idBenutzer], [benutzerName], [aktiv] FROM [Benutzer]", con);
        con.Open();
        SqlDataReader rdr = com.ExecuteReader();
    
        DropDownList1.DataBind(); // NECESSARY
        while (rdr.Read())
        {
            Debug.WriteLine(rdr.GetInt32(0) + " " + rdr.GetString(1) + " " + rdr.GetBoolean(2));
            if (DropDownList1.Items.Contains(DropDownList1.Items.FindByValue(rdr.GetInt32(0).ToString())))
            {/* do anything */ }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to bind a list of data to a data grid, but can't
Hi I'm trying to bind data to a kendochart, but no bars are appearing
When trying to use SPWeb.GetSiteData(SPSiteDataQuery) (Trying to bind some data to SPGridView), it throws
I am trying to bind a select with KnockoutJS to a predefined value that
I'm trying to bind a ComboBox to an ObservableCollection<MyType> but it's not working as
I'm trying to fire custom events using jquery but for some reason I can't
I'm trying to put into form ( select ) some values from database: val
I'm trying to get some data from my database, and then pass it into
I'm trying to detect change event for a select list as if from a
Im trying to bind a list with datetime objects to my repeater. if (e.Item.ItemType

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.