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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:36:21+00:00 2026-05-31T17:36:21+00:00

Possible Duplicate: How to save in the dropdown the value choosed? I have a

  • 0

Possible Duplicate:
How to save in the dropdown the value choosed?

I have a GridView and a column with a DropDownList instead of TextBox. The drop down has 2 values (1.No, 2.Yes).

The problem is, I can only choose the value “Yes”. The code behind works for good for yes and I also added for value No.

And another thing is if I choose a value (“Yes”, for example), how can I bring it to the top of the DropDownList, because it’s always showing the default value (the value “No”).

  • 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-31T17:36:23+00:00Added an answer on May 31, 2026 at 5:36 pm

    HTML

     <!--Add other attributes as you need to the grid view-->
     <!--NOTE: **OnRowDataBound="GridView_RowDataBound"** -->
     <asp:GridView ID="GridView1" runat="server" 
           OnRowDataBound="GridView1_RowDataBound">
     <Columns>
    
       <asp:TemplateField HeaderText="Dropdown Column">
           <ItemTemplate>
              <asp:DropDownList ID="ddlYesNo" runat="server">
                  <asp:ListItem Value="1" Text="No"></asp:ListItem>
                  <asp:ListItem Value="2" Text="Yes"></asp:ListItem>
              </asp:DropDownList>
           </ItemTemplate>
       </asp:TemplateField>
       <!-- OTHER COLUMNS -->
     </Columns>
     <!-- REST OF THE STUFF -->
    

    CODE BEHIND

     protected void GridView1_RowDataBound(Object sender, GridViewRowEventArgs e)
     {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            DropDownList ddl = (DropDownList)e.Row.FindControl("ddlYesNo");
            ddl.SelectedValue = 
              ((System.Data.DataRowView)e.Row.DataItem) ["dataColName"].ToString();
    
        }
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How do I save an Android application's state? I have an Android
Possible Duplicate: Disable browser 'Save Password' functionality In my application, I have a login
Possible Duplicate: Create Excel file in Java How to save output in excel format
Possible Duplicate: Platform independent paths in Java I make a program but it save
Possible Duplicate: Can i save lots of bitmaps to one bitmap? (2d) I wonder
Possible Duplicate: When is it OK to use an XML file to save information?
Possible Duplicate: saving data in iOS Do we have a provision profile to select
Possible Duplicate: naked asterisk as parameter in method definition: def f(*) Accessing a value
Possible Duplicate: Why are escape characters being added to the value of the hidden
Possible Duplicate: Storing echoed strings in a variable in PHP Suppose I have <?php

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.