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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:57:17+00:00 2026-05-13T18:57:17+00:00

I have a DropDownList in a template column of a GridView control. The GridView

  • 0

I have a DropDownList in a template column of a GridView control. The GridView is bound to a list of objects. Each object has a property of type int which corresponds to a value in one of the DropDownLists ListItems. I could set the selected item programatically by adding a DataBind event to the drop down, but I’m wondering if there’s a way to set the selected item by using a code block in the aspx markup.

  • 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-13T18:57:17+00:00Added an answer on May 13, 2026 at 6:57 pm

    Be cautious in this design. To create grid drop downs in this manner means that for every option in a drop down, you are going to be repeating for every single row. This can very quickly added up to page sizes that are over a MB if you have more than a few rows or multiple drop down columns, which will degrade performance.

    That being said, you can do this in the mark up by using the context binding script tags:

    <asp:DropDown id="dropDown1" SelectedValue='<%# Eval("Key") %>' runat="server"/>
    

    The context binding tags also let you call public/protected functions on the page/user control as:

    <asp:DropDown id="dropDown1" SelectedValue='<%# myFunction((int) Eval("Key")) %>' runat="server"/>
    
    public string myFunction(int key){
      return key.ToString();
    }
    

    As an alternative to producing the same repetitive HTML for every row, you could make those drop downs autocompleters or create a hidden drop down that only renders the HTML once and then uses JQuery or JavaScript to populate all your grid drop downs clientside.

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

Sidebar

Related Questions

I have a Template Column under which I have Placed a Dropdownlist. Now I
I have an ASP.NET GridView with a DropDownList (in an Item Template) and a
I have a dropdownlist in a page. The values of all the list items
If I have a DropDownList control that makes up part of a CompositeControl how
I have a repeater control where in the footer I have a DropDownList. In
Greetings! I have a DropDownList within a FormView which are bound to XmlDataSources: <asp:FormView
i have a gridview witch contain 4 databound columns and 2 templated column. in
I have a custom list template that is deployed as a .wsp. The list
In my listview object insert/edit template, I have two dropdownlists (category, subcategory). When a
I have dropdownlist and textbox and both of them have width property set to

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.