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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:03:55+00:00 2026-05-28T02:03:55+00:00

I have a gridview reliant on three cascading dropdowns (in an updatepanel). When the

  • 0

I have a gridview reliant on three cascading dropdowns (in an updatepanel). When the user edits a cell in the gridview, changes a dropdown, and clicks ‘Display’ it calls the following codebehind:

protected void Save_Click(Object sender, EventArgs e)
    {
        foreach (GridViewRow gvr in MasterDisplay.Rows)
            MasterDisplay.UpdateRow(gvr.RowIndex, false);
        MasterDisplay.DataBind();
}

The problem is that the dropdowns will change the gridview, so the updated cells get out of order. An example: Let’s say I have six items: A1, A2, A3, B1, B2, B3. If I edit price for B2, then change the dropdown that says ‘show Bs first’, on the resulting page I’ll see the new price for A2 instead (ie, whatever is fifth in the order).

I figure this is because in UpdateRow() we’re only updating based on the index (gvr.RowIndex), so somehow the GridView is getting redisplayed (without losing the new price data!) and then updated.

Any ideas on how to ensure that these changes save to the appropriate row, rather than just the row that happens to now have the same index as previously?

  • 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-28T02:03:55+00:00Added an answer on May 28, 2026 at 2:03 am

    So, as is becoming common, I guess I’ll answer my own question in case one day someone stumbles upon this. (ie http://xkcd.com/979/)

    Basically, I created three labels that are fed variables from Request.QueryString on Page_Load (where the variables are passed in the url). These labels are now the ControlParameters for the SqlDataSource building the gridview. I also fill the dropdowns from this variable. ie

    var myInternalVar1 = Request.QueryString["myVariable1"];
    myLabel1.Text = myInternalVar1;
    myDropDown1.SelectedValue = myInternalVar1;
    

    Then the user can use dropdowns as normal (from their end). When the user clicks save, I run the current code (see question) and then add:

    myLabel1.Text = myDropDown1.SelectedValue;
    Response.Redirect("~/mysite.aspx?myVariable1=" + myLabel1.Text);
    

    This means no more postbacks, but instead navigation.

    One important note: I had to fill all dropdowns in if(!Page.IsPostBack) because the pre-existing functions I piggybacked on seemed to be getting called multiple times. Not sure why they were called since they were only in one declaration
    ( got called three times after dropdown was used, even though outside gridview is outside updatepanel)

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

Sidebar

Related Questions

I have a gridview inside UpdatePanel. One of the column in gridview is link
I have a GridView on Android I populate with custom images. When the user
I have two forms.. form1 and form2 in form1 i have gridview with three
I am using a GridView within an updatepanel. I have gridview generated edit and
I have a gridview and a label in an updatepanel. I want to change
I have GridView which I can select a row. I then have a button
Have a gridview control which will show X amount of rows. I want to
I have a GridView control in an Asp.net application, that has a <asp:buttonField> of
I have a GridView where one column is bound to an object property containing
I have a GridView defined like this: <asp:GridView ID=myGridView ruant=server> <asp:BoundField DataField=myField /> <asp:CommandField

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.