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

In the aspx code view , we can code like this: <asp:ListBox runat=server> <asp:ListItem
This is my .aspx page code: - <asp:Button ID=btnProcess runat=server Text=Place OnClick=btnProcess_Click CommandArgument='<%# Eval(intId)
When I write code like this: <asp:DetailsView ID=DetailsView1 Runat=server DataSourceID=Vote DefaultMode=Insert AutoGenerateRows=False DataKeyNames=id Width=352px
I have the following structure in an aspx page: <asp:Panel ID=pnlCust runat=server> <asp:GridView ID=gvMaster
I have an ASP.NET web site with something similar to the following code: .aspx
Language: asp This is sample of my code: str = www.example.com/gotobuy.aspx?id=1234 key_word = .obuy.
I have an ASP.NET page with code-behind in VB.NET. On the ASPX page I
<asp:GridView runat=server ID=gridUserAccounts SkinID=gridviewSkin PageSize=5> <Columns> <asp:BoundField HeaderText=User Name DataField=UserName /> <asp:BoundField HeaderText=Email SortExpression=Email
ASP.NET has a reorderlist control http://www.asp.net/ajax/ajaxcontroltoolkit/Samples/ReorderList/ReorderList.aspx Is there anything equivalent (control, source code, ...)
Putting code at aspx files is slower? The code is recompiled every access? At

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.