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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:53:29+00:00 2026-06-14T08:53:29+00:00

I have a GridView with more than 30 columns. Most are plain controls but

  • 0

I have a GridView with more than 30 columns. Most are plain controls but for some I have added a template control (DropDownList, Calendar and CheckBox control). Here is the aspx code for the control in question

     <asp:TemplateField HeaderText="Field1 Caption" SortExpression="Field1">
         <ItemTemplate>
            <asp:Label ID="lblConstructionArea" runat="server" Text='<%# Eval("Field1") %>'></asp:Label>
         </ItemTemplate>
         <EditItemTemplate>
              <asp:DropDownList ID="ddlField1" EnableViewState="true" runat="server"></asp:DropDownList>
          </EditItemTemplate>
      </asp:TemplateField>

I wanted a dropdown to be shown on the column when a user clicked on Edit. So I add this code (and the above EditItemTemplate)

  protected void gvData_RowEditing(object sender, GridViewEditEventArgs e)
    {
        string fieldOne = CommonUtils.ExtractControlValue(e,"lblField1",gvData);

        gvData.SelectedIndex = e.NewEditIndex;
        gvData.EditIndex = e.NewEditIndex;
        gvData.DataBind();

        BindGridDropDownData(e, CommonUtils.GetConstructionAreas() ,"ddlConstructionArea", constructionArea, "Field1", fieldOne);
    }

In the above code I am getting the current available and passing it to another method so that when the dropdown is displayed the selected index can be shown accurately. After this I do a change on the dropdownlist and click on the “Update button” on the GridView and the following event is triggered

   protected void gvData_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        int rowEditIndex = e.RowIndex;
        GridViewRow gRow = gvData.Rows[rowEditIndex];


        DropDownList ddlConstructionArea = (DropDownList) gvData.Rows[rowEditIndex].FindControl("ddlConstructionArea"); //This does not work

        ddlConstructionArea = (DropDownList)gRow.FindControl("ddlConstructionArea");//This does not work 

        ddlConstructionArea = (DropDownList)gvData.Rows[rowEditIndex].Cells[7].FindControl("ddlConstructionArea");//this does not work either
        gvData.EditIndex = -1;//this works and the text boxes disappear
        gvData.DataBind();//this works and the old data shows up on the gridview
    }

I am curious as to how to do an update on a Grid where I have the binding is runtime.

  • 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-14T08:53:31+00:00Added an answer on June 14, 2026 at 8:53 am

    The problem was with the way the grid was being bound. I had written code to refresh the grid on page load and anytime I clicked on the Edit button the page was being refreshed and the grid binding was getting triggered instead of the updating event. I removed the code refreshing the grid on page load and put it in the places where it is needed and the order of events were getting triggered the way I would want it to and the update worked perfectly without a problem.

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

Sidebar

Related Questions

I have a grid view with more than one control (ie. a DropDownList and
I have a GridView with 4 images per row, and normally has more than
I have a gridview that when more than 10 items are in the view,
Have a gridview control which will show X amount of rows. I want to
I have more than 30,000 rows in a table. It takes a lot of
I have a table in sq server db having more than 1 million rows.
Is it possible to loop through a gridview with more than one page, the
I have a gridview that is set up to do paging but it is
I have checkbox control on gridview with the ability to check all and uncheck
I want to check that a textbox doesnt have more than one decimal point

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.