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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:51:03+00:00 2026-05-11T06:51:03+00:00

I searched for a few days now but didn’t find a solution. So here

  • 0

I searched for a few days now but didn’t find a solution. So here is my scenario:

I have a DetailView with a DataBindung to a database and DefaultMode set to ‘Insert‘ as a input-form for a new db-entry. One field in this DetailsView is a TemplateField with a InsertItemTemplate containing a DropDownList. This DropDownList is also bounded to another SqlDataSource, using a select-parameter ‘UserID’ to get all rows of a database for the actual logged-in user. Those rows are shown in my DropDownList and when looking at the sourcecode in my browser I see the correct ‘option’-attributes with all those nice db-IDs in their corresponding value. So everything is fine to this point.

Now I press my Insert-Button to send my data back to the server. But when trying to get the selected value from my DropDownList in DetailsView1_ItemInserting() with the following code I get a null-value.

var list = (DropDownList)DetailsView1.Rows[0].FindControl( 'DropDownList1' ); InsertEntryDataSource.InsertParameters['DropDownList1Value'].DefaultValue = list.Items[list.SelectedIndex].Value; 

The same code works with another form I created in this project. The only difference is, that the other DropDownList is bounded to a DataSource without a select-parameter I have to set on runtime (the current logged-in UserID).

My resumption was that the DropDownList is empty after the postback because the databinding wasn’t yet done. So I set the select-parameter for the SqlDataSource my DropDownList is bounded to in DetailsView1_ItemInserting() – and now the above line got my value.

BUT: I just tested the form another time and I determined, that no matter which entry I select in my DropDownList, I get always the value of the first entry! The whole procedure seems to clear my SelectedIndex of the DropDownList – so now I have a value to insert instead of null, but it’s the wrong one. 🙁

So my question: How can I access the selected value of my DropDownList in DetailsView1_ItemInserting() to save it to the database?

Thanks in advance, Anheledir

  • 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. 2026-05-11T06:51:03+00:00Added an answer on May 11, 2026 at 6:51 am

    You can use this syntax to access the ddl without writing code:

    <InsertParameters> <asp:ControlParameter ControlID='DetailsView1$DropDownList1' Name='DropDownList1' PropertyName='SelectedValue' Type='String' /> </InsertParameters> 

    or from the DataSource_Inserting event and not the DetailsView_ItemInserting event u can do this:

      e.InputParameters['InputParameterFieldName'] = ((DropDownList)DetailsView1.FindControl('DropDownList1')).SelectedValue; 

    Good Luck!

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

Sidebar

Ask A Question

Stats

  • Questions 264k
  • Answers 264k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Yes. Valid Ethernet frames have a minimum size of 64… May 13, 2026 at 12:16 pm
  • Editorial Team
    Editorial Team added an answer The standard UITableViewCell only supports one image (via the imageView.image… May 13, 2026 at 12:16 pm
  • Editorial Team
    Editorial Team added an answer $test = call_user_func(array($className, 'getInstance')); See call_user_func and callbacks. May 13, 2026 at 12:16 pm

Related Questions

I searched for a few days now but didn't find a solution. So here
This problem has been kicking my butt for a few days now. I have
Note : This question has been re-asked with a summary of all debugging attempts
I am working on an application which works with GPS data. Part of the
I apologize for any confusion from the question title. It's kind of a complex

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.