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 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
  • 3 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

Related Questions

I have searched for a few days now, high and low and have not
I have searched far and wide here but with no solution to my problem
So I have searched through a few question here regarding the AlertDialog, and I'm
This is quite a noobish question, I have searched for a few hours now
Last few days I searched all over the internet to solve this problem but
I have been learning iOS development for a few days now. At this moment,
I have been researching this topic for a few days now and i'm still
I have searched for a few days on the internet how to create a
I searched the documentation but didn't find anything and wanted to be sure. I
This problem has been kicking my butt for a few days now. I have

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.