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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:41:50+00:00 2026-06-16T00:41:50+00:00

We are trying to update data to the database from an ASP.Net DetailsView with

  • 0

We are trying to update data to the database from an ASP.Net DetailsView with a value from an ASP:DropDownList but when the user clicks the Update button nothing happens. Only the Cancel button will work.

The DropDownList will show the data from the database that was loaded into it but we can’t do an Update.

I’m assuming I’m missing something from the markup coding.

Here’s the markup for the DropDownList:

<asp:TemplateField HeaderText="Class:" SortExpression="ClassID">

    <EditItemTemplate>
        <asp:DropDownList 
            ID="DropDownListClass" 
            Runat="server"
            DataSourceID="SqlDataSourceClasses"
            DataTextField = "ClassName"
            DataValueField="ID"
            AutoPostBack="True" 
            AppendDataBoundItems="true">
        </asp:DropDownList>

        <asp:RequiredFieldValidator ID="RequiredFieldValidatorEditDropDownListClass" runat="server" 
            ControlToValidate="DropDownListClass" 
            ErrorMessage="Please select a class." Font-Bold="True" Font-Italic="True" ForeColor="Red" 
            SetFocusOnError="True" Display="Dynamic">
        </asp:RequiredFieldValidator>
    </EditItemTemplate>

    <ItemTemplate>
        <asp:Literal ID="LiteralClass" runat="server" 
            Text='<%# FormatAsMixedCase(Eval("ClassName").ToString())%>' />
    </ItemTemplate>

    <ItemStyle ForeColor="Blue" />
</asp:TemplateField>

This is the markup of the DataSource which is a simple lookup table:

<asp:SqlDataSource 
    ID="SqlDataSourceClasses" 
    runat="server" 

    ConnectionString="<%$ ConnectionStrings:Islamic Knowledge Academy Staff System %>" 

    SelectCommand="SELECT [ID], [ClassName], [Grade] FROM [Classes]">
</asp:SqlDataSource>
  • 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-16T00:41:51+00:00Added an answer on June 16, 2026 at 12:41 am

    Emad-ud-den,

    I think you need a click handler for your submit button so that when the client posts back to the server – it knows to update the database. Something along the lines of:

    Sub btnUpdate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
    
        Dim cnAD As New System.Data.SqlClient.SqlConnection = yourdatasource.getConnection("SqlDataSourceClasses", cnAD)
        Dim cmd As New SqlCommand
        cmd.Connection = cnAd
        cmd.CommandType.Text
        cmd.CommandText = "update yourtable set yourval=@val where yourparams"
        cmd.Paramaters.AddWithValue("@val", DropDownListClass.SelectedValue)
        cmd.ExecuteNonQuery()
    
    End Sub
    

    You could even add a try-catch to get a better idea as to where your code is going awry. Please note that what I’ve written will not work as is, but that it is intended to point you in the right direction.

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

Sidebar

Related Questions

I am trying to write an update statement for inserting data from asp.net gridview
Okey so i'm trying to update information in my database from a form. But
I'm trying to update table data from a database in CakePHP. Query: UPDATE status
I'm trying to update the data from my oracle database using this code. The
I am trying to update data while I am reading them from database, see
I am trying to update table A with data from table B. I thought
I am trying to update a field in a table with data from another
I am trying to Update a table in an access database from C#. It
I am trying to insert into Microsoft Access database from VB.net. I can read
I'm trying to update the data in my SQLite database on iPhone. I'd like

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.