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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:58:41+00:00 2026-05-20T03:58:41+00:00

I have a templated Gridview where I only want to display one column (Questions

  • 0

I have a templated Gridview where I only want to display one column (Questions — these are database obtained), and the other the dropdownlist of possible answers (Options). The dropdownlist’s values change depending on the type of the question. There are only 2 types: T/F or ranged (Lo, Med, High). So if the question is type 1, the dropdownlist should just display T/F. Likewise if it’s type II.

Shown below is the gridview and the method that loads the dropdownlist (supposedly):

    <asp:GridView AutoGenerateColumns="false" runat="server" ID="SurveyView">
    <Columns>

        <asp:BoundField HeaderText="Questionnaire" DataField="Questionaire" ReadOnly="true"/>
        <asp:BoundField HeaderText="QuestionID" DataField="Id" ReadOnly="true" Visible="false" />
        <asp:BoundField HeaderText="IsBoolean" DataField="Filter" ReadOnly="true" Visible="false" />
        <asp:TemplateField HeaderText="Response">
            <ItemTemplate>
                <asp:DropDownList ID="UserDropDown" runat="server" AppendDataBoundItems="true" DataSource="LoadDropdownList(Filter)" DataTextField="key" DataValueField="value"></asp:DropDownList>
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>


        public Dictionary<String, String> GenerateDropdownList(bool BooleanFilterStatus)
    {
        Dictionary<String, String> tempStores = new Dictionary<string, string>() ; 
        if (BooleanFilterStatus)
        {
            tempStores.Add(Boolean.TrueString, Boolean.TrueString);
            tempStores.Add(Boolean.FalseString, Boolean.FalseString);
        }
        else
        {
            tempStores.Add("NONE", "NIL");
            tempStores.Add("Lo", "Low");
            tempStores.Add("Medium", "Medium");
            tempStores.Add("High", "High"); 
        }

        return tempStores; 
    }

I was hoping that by using LoadDropdownList(), it would be populating the list. But that does not appear to work.

Any ideas or other possible solution would be appreciated.

  • 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-20T03:58:42+00:00Added an answer on May 20, 2026 at 3:58 am

    How about something like

    <asp:DropDownList ID="UserDropDown" runat="server" AppendDataBoundItems="true" 
     ondatabinding="DropDownList1_DataBinding" DataTextField="key" DataValueField="value"></asp:DropDownList>
    

    and in code-behind

     protected void DropDownList1_DataBinding(object sender, EventArgs e)
        {
            var ddl = sender as DropDownList;
            if(ddl!=null)
            {
              //populate list. 
              ddl.Items.Add(new ListItem("test"));
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ListView. When I select a row I want that only one
i have a gridview witch contain 4 databound columns and 2 templated column. in
I have a webform gridview. In that one columns is password. I want to
I have built a gridview that includes one bound column on the far left
I have a button inside of a gridview's template field. Onclick i want to
I have a gridview that displays items details, I added two template fields one
I have a templated class that I want to avoid copying (because of the
I have a listview where I have templated the column headers and the listview
Say I have a label inside a gridview template column and I assign the
I have a Checkbox template column in a ASP.NET 3.5 GridView. Now the user

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.