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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:00:10+00:00 2026-05-27T11:00:10+00:00

I have one problem with a gridview control and maybe someone can help me.

  • 0

I have one problem with a gridview control and maybe someone can help me.
In the gridview, there is a field Country which comes from the database.
I have enabled editing the data in the gridview, and when someone will click the gridview edit button, the gridview will come up and offer them to select the new value for that field.

But when I am clicking Edit, I am getting this error :

‘Type ‘System.Web.UI.WebControls.ListItem’ in Assembly ‘System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ is not marked as serializable.’

Here is the code I have for that field, in shorter version, excluding most of the countries from the example:

<asp:TemplateField HeaderText="Country" SortExpression="Country">
    <ItemTemplate>
        <asp:Label ID="Label1" runat="server" 
                   Text='<%# Bind("Country") %>'>
        </asp:Label>
    </ItemTemplate>
    <EditItemTemplate>
        <asp:DropDownList id="ddlCountry" 
                          SelectedItem='<%# Bind("Country") %>' 
                          runat="server">
            <asp:ListItem Value="N/A">Please select</asp:ListItem>
            <asp:ListItem Value="US">United States</asp:ListItem>
            <asp:ListItem Value="AF">Afghanistan</asp:ListItem>
            <asp:ListItem Value="AL">Albania</asp:ListItem>
            <asp:ListItem Value="DZ">Algeria</asp:ListItem>
            <asp:ListItem Value="AS">American Samoa</asp:ListItem>
            <asp:ListItem Value="AD">Andorra</asp:ListItem>
            <asp:ListItem Value="AO">Angola</asp:ListItem>
            <asp:ListItem Value="AI">Anguilla</asp:ListItem>
            <asp:ListItem Value="AQ">Antarctica</asp:ListItem>
            <asp:ListItem Value="AG">Antigua And Barbuda</asp:ListItem>
            <asp:ListItem Value="AR">Argentina</asp:ListItem>
            <asp:ListItem Value="AM">Armenia</asp:ListItem>
            <asp:ListItem Value="AW">Aruba</asp:ListItem>
            <asp:ListItem Value="AU">Australia</asp:ListItem>
            <asp:ListItem Value="AT">Austria</asp:ListItem>
            <asp:ListItem Value="ZR">Zaire</asp:ListItem>
            <asp:ListItem Value="ZM">Zambia</asp:ListItem>
           <asp:ListItem Value="ZW">Zimbabwe</asp:ListItem>   
        </asp:DropDownList>
    </EditItemTemplate>
  • 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-27T11:00:11+00:00Added an answer on May 27, 2026 at 11:00 am

    Have you tried creating a datasource for your countries, then just putting the DropDownList into the edittemplate and assigning the datasource from code behind? This will get around explicitly creating a ListItem object into the GridView. Here is an long-winded example using a DataSource: msdn.microsoft.com/en-us/library/ms972948.aspx.

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

Sidebar

Related Questions

I have one problem , I want to get some data from XML file
I'm almost finished with my program, but I have one problem that I can't
The problem: we have one application that has a portion which is used by
I am trapped in one problem. I have a page which contains some taxboxes.
Can you easily right-align just one column in a GridView? I have this <asp:GridView
I have data that gets displayed in gridview. If I'm pulling it from one
I have one GridView which has multiple columns. Here I just mentioned only the
In gridview control, am using RowEditingevent. I have created a command field to handle
I have this weird gridview problem in .net, I haven't found what can be
I have one problem to work with NSMutableData . I defined one NSMutableData *receivedData

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.