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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:48:13+00:00 2026-06-07T05:48:13+00:00

// aspx code <asp:DropDownList ID=DropDownList1 runat=server DataTextField=fullname DataValueField=username AutoPostBack=True Width=125px Height=22px></asp:DropDownList> // Code behind

  • 0

// aspx code

   <asp:DropDownList ID="DropDownList1" runat="server" DataTextField="fullname" DataValueField="username" AutoPostBack="True" Width="125px" Height="22px"></asp:DropDownList>

// Code behind

 SqlConnection myConnection = new SqlConnection("Server=xyz;Database=db;Uid=db;Pwd=12345");
 myConnection.Open();         
 SqlDataReader myReaderddl = null;
 SqlCommand myCommandddl = new SqlCommand("SELECT [username], [fullname] FROM [qa_users]", myConnection);
 myReaderddl = myCommandddl.ExecuteReader();
 myReaderddl.Read();
 ddlrep.DataSource = myReaderddl;                    
 ddlrep.DataValueField = "[username]";
 ddlrep.DataTextField = "[fullname]";
 ddlrep.DataBind();
 myReaderddl.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-07T05:48:14+00:00Added an answer on June 7, 2026 at 5:48 am

    I haven’t tested this code, but it should work.

    using (var myConnection = new SqlConnection("Server=xyz;Database=db;Uid=db;Pwd=12345"))
    {
        using (var myCommandddl = new SqlCommand("SELECT [username], [fullname] FROM [qa_users]", myConnection))
        {
            var table = new DataTable();
    
            using(var myAdapter = new SqlDataAdapter(myCommandddl))
                myAdapter.Fill(table);
    
            ddlrep.DataSource = table;
            ddlrep.DataValueField = "username";
            ddlrep.DataTextField = "fullname";
            ddlrep.DataBind();
        }
    }
    

    There’s a couple changes I made that you should note:

    • Use of a USING statement. This offers a number of benefits, such as automatically calling Dispose() on your IDisposable objects, regardless of whether an Exception is thrown. In my opinion, it’s a nice visual for showing when and where an object is being disposed. http://msdn.microsoft.com/en-us/library/yh598w02.aspx
    • Not using a SqlDataRader directly, rather, use of the SqlDataAdapter to fill the table: http://msdn.microsoft.com/en-us/library/879f39d8
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

//code in aspx. </asp:TemplateField> : : : <ItemTemplate> <asp:DropDownList ID=didDdl runat=server DataSourceID=departmentsDataSource DataTextField=Department DataValueField=DepartmentID
This is my code in aspx: <EditItemTemplate> <asp:DropDownList ID=DropDownList1 runat=server DataSourceID=SqlDataSource2 SelectedValue='<%#GetSYSACCID(Eval(SYSACCID))%>' DataTextField=UserName DataValueField=SYSACCID>
I have an asp.net dropdown like this <asp:DropDownList width=95% ID=RessourceComposantes runat=server DataSourceID=Composantes DataTextField=Description DataValueField=ComposanteID>
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
I have the following drop down list: <asp:DropDownList runat=server ID=ddlShipping CssClass=shippingMenu AutoPostBack=true> <asp:ListItem Text=3-5
In the aspx code view , we can code like this: <asp:ListBox runat=server> <asp:ListItem
Here is how my code is: page.aspx: <asp:Image ID=Image1 runat=server /> Code behind: byte[]
i use jquery serialize() with asp.net server controls. <asp:DropDownList ID=ddFirmaAd runat=server Width=180 Height=25> </asp:DropDownList>
I have a aspx Page where I am using AJAX. like <asp:UpdatePanel runat=server ID=upPanelDDLProgram>
This is my aspx <asp:Content ID=Content2 ContentPlaceHolderID=ContentPlaceHolder1 runat=server> <asp:ObjectDataSource ID=DSCategories runat=server SelectMethod=GetCategories TypeName=BAL.CategoryBAL> </asp:ObjectDataSource>

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.