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

  • Home
  • SEARCH
  • 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 7871443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:54:26+00:00 2026-06-03T01:54:26+00:00

I have a gridview with a dropdownlist column, and i enabled the paging function.

  • 0

I have a gridview with a dropdownlist column, and i enabled the paging function. The problem is every time after it turns to the next page, the selected value of the dropdownlist on the previous page is back to default value.

I tried to wrap the code with if(!ispostback), only the first page available other pages are disappear

protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            List<CPDEmployee> employeelist = (List<CPDEmployee>)Cache["EmployeeList"];

            unverifiedlist.DataSource = employeelist;
            unverifiedlist.AllowPaging = true;
            unverifiedlist.PageSize = 10;
            unverifiedlist.DataBind();
        }
    }
protected void PageSelect_SelectedIndexChanged(object sender, EventArgs e)
{
    int page = int.Parse(PageSelect.SelectedItem.Text);
    unverifiedlist.PageIndex = page;
    DataBind();
}





 <asp:GridView ID="unverifiedlist" runat="server" AutoGenerateColumns="false" AllowSorting="true" AllowPaging="true" ViewStateMode="Enabled">
                        <Columns><asp:TemplateField HeaderText="Options" >
                                <ItemTemplate>
                                    <asp:DropDownList ID="options" runat="server" AutoPostBack="true">
                                        <asp:ListItem Value="1">Verified</asp:ListItem>
                                        <asp:ListItem Value="0">Rejected</asp:ListItem>
                                    </asp:DropDownList>
                                </ItemTemplate>
                             </asp:TemplateField>
                    </Columns>
                    <PagerSettings Visible="false"/>            
        </asp:GridView>
<asp:DropDownList ID="PageSelect" runat="server" AutoPostBack="true" OnSelectedIndexChanged="PageSelect_SelectedIndexChanged"></asp:DropDownList>

does anyone know how to fix it, where should I put ispostback? thanks

  • 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-03T01:54:29+00:00Added an answer on June 3, 2026 at 1:54 am

    You need to handle OnRowDataBound and set the appropriate element programmatically. Example:

    <asp:GridView ID="unverifiedlist" runat="server" 
       OnRowDataBound="unverifiedlist_RowDataBound" AutoGenerateColumns="false" 
        AllowSorting="true" AllowPaging="true" ViewStateMode="Enabled">
    

    And implement something like:

    protected void unverifiedlist_RowDataBound(Object sender, GridViewRowEventArgs e)
    {
      if(e.Row.RowType == DataControlRowType.DataRow)
      {
         ((DropDownList)e.Row.FindControl("options")).SelectedValue=((CPDEmployee)e.Row.DataItem).Unverified;
    
      }
    }
    

    Assuming, obviously, that you have a Property called Unverified on your business object. You should use whatever is appropriate. This is just an example.

    UPDATE:

    Since the drop down inside the grid is auto posting back, I would add an event handler for OnSelectedIndexChanged to the drop down list inside the Grid. Something like:

    <asp:DropDownList ID="options" runat="server" AutoPostBack="true" OnSelectedIndexChanged="options_SelectedIndexChanged">
      <asp:ListItem Value="1">Verified</asp:ListItem>
      <asp:ListItem Value="0">Rejected</asp:ListItem>
    </asp:DropDownList>
    

    And then

    protected void options_SelectedIndexChanged(object sender, EventArgs e)
    { 
        string selecteValue = ((DropDownList)sender).SelectedValue;
        //Now persist this value in the appropriate business object  
        //this is the difficult part because you don't know for which row in the gridview
        //you are changing this selection. You'll need to devise a way to pass an extra 
        //value (an Employee ID, I would imagine) that would allow you to grab the 
        // record from the List<CDPEmployee> and change the property to the new selection.
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a DropDownList in a template column of a GridView control. The GridView
hi I have this gridview like this. <asp:DropDownList ID=triggerDropDown runat=server AutoPostBack=true onselectedindexchanged=triggerDropDown_SelectedIndexChanged> <asp:GridView ID=myGridView
I have a dropdownlist inside a gridview, that is loaded from a datasource when
I have got 2 DropDownList s on my Form and 1 GridView . I
i have a gridview witch contain 4 databound columns and 2 templated column. in
I have a bit of trouble with getting dropdownlist selected value we have in
I have a dropdownlist, and a Gridview where one of the columns is a
I have a gridview , with the following columns: I've transformed the column cell
I have a gridview with column that have droplist when enter edit mode: <asp:TemplateField
I have a GridView with a column of checkboxes (the rest of the GridView

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.