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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:58:13+00:00 2026-05-25T19:58:13+00:00

I am using a dropdownlist in footer row of gridview ( ASP.Net ) and

  • 0

I am using a dropdownlist in footer row of gridview(ASP.Net) and I fill that on rowdatabound event,first time it works fine but when the form is postbacked,dropdown gets cleared.

It can be solved by refilling it on each postback,but I want that only single time code binding call fulfill my need,
means is there any way to stop from being null on postback.

looking for your kind solutions and suggestions
Thnx in advance……

Supriya

Code:

protected void gvProjects_RowDataBound(object sender, GridViewRowEventArgs e)
{

    try
    {

        if (gvProjects.Rows.Count > 0 && e.Row.RowIndex != -1)
        {
            string proj_Id = Convert.ToString(gvProjects.DataKeys[e.Row.RowIndex].Value);
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                DropDownList ddlProject = (DropDownList)e.Row.FindControl("ddlProject");
                if (ddlProject != null && ddlProject.Items.Count == 0)
                {
                    objMaster.FillProjects(ddlProject);
                    ddlProject.SelectedValue = proj_Id;
                }
            }

        }
    }
    catch (Exception excep)
    {
        lbl_msg.Text = excep.Message;
    }
}

It’s called whenever the grid is binded,can it be avoided.

  • 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-25T19:58:13+00:00Added an answer on May 25, 2026 at 7:58 pm

    With this code you will avoid filling the dropdownlist located in the gridview footer in each rowdatabound:

        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType != DataControlRowType.Footer)
            {
                //do the binding for the normal rows
            }
        }
    

    As you can see, the rowdatabound will be only executed on the header and normal rows but not in the footer.

    Hope this helps!

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

Sidebar

Related Questions

I am using Asp.net dropdownlist in one of my form ..I have two dropdown
I'm using Chosen JQuery Plugin for a ASP.NET MVC (Razor) Project. For a Dropdownlist
I am using the Html.DropDownList helper in ASP.NET MVC and I would like to
How to bind xml file to asp.net dropdownlist using xmldatasource? If I do it
how can I populate an ASP.NET dropdownlist using javascript? also how can I clear
i am using QueryExtender with dropdownlist to filter gridview ( datasource : EntityDataSource). <asp:SearchExpression
I am using two dropdownlist in gridview. Total 5 to 7 rows in gridview.
i have two select using as a dropdownlist for country/state everything works as i
I am using vb.net language I have a dropdownlist, which is filled by below
I have a cascade dropdownlist when the first change value the second change using

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.