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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:18:29+00:00 2026-05-23T00:18:29+00:00

//code in aspx. </asp:TemplateField> : : : <ItemTemplate> <asp:DropDownList ID=didDdl runat=server DataSourceID=departmentsDataSource DataTextField=Department DataValueField=DepartmentID

  • 0

//code in aspx.

   </asp:TemplateField>
        :
        :
        :
   <ItemTemplate>
   <asp:DropDownList ID="didDdl" runat="server" 
    DataSourceID="departmentsDataSource" 
    DataTextField="Department" 
    DataValueField="DepartmentID" 
    SelectedValue='<%# Bind("DepartmentID") %>' 
    Enabled="False" />
   </ItemTemplate>
   </asp:TemplateField>

Q:I have to insert the selected dropdownlist items to a table all at a once i.e when i click a submit button(which i have not shown here) then all the selected values should go at a time to a table.

  • 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-05-23T00:18:29+00:00Added an answer on May 23, 2026 at 12:18 am

    My assumption is you are using Gridview. So this will work.

    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        List<string> lst = new List<string>();
    
        foreach(GridViewRow gvr in GridView1.Rows)
        {
            if (gvr.RowType == DataControlRowType.DataRow)
            {
                lst.Add(((DropDownList)gvr.FindControl("didDdl")).SelectedValue);
            }
        }
    }
    

    Improvised solution

    protected void btnSubmit_Click(object sender, EventArgs e)
    {
    
        SqlCommand comm = new SqlCommand();
    
        StringBuilder sb = new StringBuilder("INSET INTO [Table] ");
    
        string template = " SELECT @{0} UNION ALL ";
    
    
        foreach(GridViewRow gvr in GridView1.Rows)
        {
            if (gvr.RowType == DataControlRowType.DataRow)
            {
                string value = ((DropDownList)gvr.FindControl("didDdl")).SelectedValue;
    
                sb.AppendFormat(template, value);
                comm.Parameters.Add(new SqlParameter("@" + value, value));
    
            }
        }
        comm.CommandText = sb.ToString()
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a this aspx-code: (sample) <asp:DropDownList runat=server ID=ddList1></asp:DropDownList> With this codebehind: List<System.Web.UI.WebControls.ListItem> colors
ASPX Code <asp:RadioButtonList ID=rbServer runat=server > <asp:ListItem Value=<%=ServerDeveloper%>> Developer </asp:ListItemv <asp:ListItem Value=dev.ahsvendor.com> dev.test.com</asp:ListItem> <asp:ListItem
When I write code like this: <asp:DetailsView ID=DetailsView1 Runat=server DataSourceID=Vote DefaultMode=Insert AutoGenerateRows=False DataKeyNames=id Width=352px
the below ASPX code is ok : <asp:Label ID=lblShowInRPV1 runat=server Text=<%# Method() %>></asp:Label> is
I have the following ASPX code: <asp:ScriptManager ID=ScriptManager1 runat=server /> <asp:UpdatePanel runat=server ID=UpdatePanel UpdateMode=Conditional>
I need help on this following aspx code aspx Code: <asp:Label ID =lblName runat
I have the following structure in an aspx page: <asp:Panel ID=pnlCust runat=server> <asp:GridView ID=gvMaster
This is the code from .aspx file <html xmlns=http://www.w3.org/1999/xhtml> <head runat=server> <title>Login Again</title> <script
Here is a code snippet for an asp:Wizard control I have on an aspx
I am currently publishing code behind .aspx in SharePoint. I can automatically publish the

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.