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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:29:01+00:00 2026-06-11T05:29:01+00:00

I put Dropdownlist inside my GridView1, and the dropdownlist has values 0 and 1.

  • 0

I put Dropdownlist inside my GridView1, and the dropdownlist has values 0 and 1. What I want is: depending on the selected value from dropDownlist to update the column [Status] whit that value in my sql database???

protected void SQL_Update(object sender, GridViewUpdateEventArgs e){

SqlConnection conn = new SqlConnection();
conn.ConnectionString = @"Data Source=.\SQLEXPRESS;Initial Catalog=Korisnik;Integrated Security=True";
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "UPDATE RegistracijaKorisnik SET Status = " + ((DropDownList)GridView1.Rows[e.RowIndex].FindControl("DropDownList2")).SelectedValue; ;
cmd.Connection = conn;

conn.Open();
cmd.ExecuteNonQuery();

conn.Close();}
  • 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-11T05:29:03+00:00Added an answer on June 11, 2026 at 5:29 am

    Let’s say you have the DropDownList and you bind it whichever way:

    <asp:GridView ID="Grid" runat="server" OnRowUpdating="SQL_Update">
      <asp:TemplateField> 
        <EditItemTemplate>
          <asp:Button ID="Btn" runat="server" CommandName="Update" Text="Update" />
        </EditItemTemplate>
      </asp:TemplateField> 
      <asp:TemplateField>
        <EditItemTemplate>
          <asp:DropDownList ID="ddl" runat="server" /> 
        </EditItemTemplate> 
      </asp:TemplateField> 
    </asp:GridView>
    

    In your code behind, you should have an Updating event, specifically using GridViewUpdateEventArgs e

    protected void SQL_Update(object sender, GridViewUpdateEventArgs e)
    {
       /*
         You'll have to find the control in the GridView, using FindControl, and cast it to a DropDownList  
         Using ddl.SelectedValue isn't going to work
       */
       string sql = "Update table set Status = " + ((DropDownList)Grid.Rows[e.RowIndex].FindControl("ddl")).SelectedValue 
       //Other SQL logic here
    
       //Commit the database changes, using whichever SQL driver you have.
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to remove datepicker function depending on the dropdownlist selected value. I try
I want to make my dropdownlist selected first value --select-- when first load page
Put simply, I want to select all data in two columns from each of
I got a question concerning a DropDownList with a selected value. @Html.DropDownListFor(m => m.weekForEachDayService[6].serviceId,
I want to bind Data from DB to DropDownList ,i had tried the following
Scenarios I am using DataGrid with a column containing DropDownList . When I update
I have a dropdownlist for which I am loading data from excel. Excel has
How to put the first item on the DropDownList in blank ? In VB
Put value as a field makes sense only if this one represents some object's
I put a dropdownlist on a webform and give a list as datasource. But

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.