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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:18:51+00:00 2026-06-01T09:18:51+00:00

I have editable grid view, If I click on edit in any row say

  • 0

I have editable grid view, If I click on edit in any row say “x”, it opens in edit mode, however if I click on any other row, say “y”, “x” should cancel edit. But In my code after clicking on “y”, both the rows remains in edit mode.

protected void gvViewAdmins_RowEditing(object sender, GridViewEditEventArgs e)
{
    gvViewAdmins.EditIndex = e.NewEditIndex;

    Label lblEmailId = gvViewAdmins.Rows[e.NewEditIndex].FindControl("gvlblEmail") as    Label;
    lblEmailId.Visible = false;
    ViewState["currentEmailId"] = lblEmailId.Text;

    TextBox textboxEmailId = gvViewAdmins.Rows[e.NewEditIndex].FindControl("gvtbEmailId") as TextBox;
    textboxEmailId.Text = ViewState["currentEmailId"].ToString();
    textboxEmailId.Visible = true;

    Label lblRole = gvViewAdmins.Rows[e.NewEditIndex].FindControl("gvlblRole") as Label;
    lblRole.Visible = false;
    ViewState["currentRole"] = lblRole.Text;

    DropDownList dropdownRoles = gvViewAdmins.Rows[e.NewEditIndex].FindControl("gvddlRoles") as DropDownList;
    this.PopulateRole(dropdownRoles);
    dropdownRoles.Visible = true;
    this.SelectRoleDropDownValue(dropdownRoles);

    LinkButton lbtnUpdate = gvViewAdmins.Rows[e.NewEditIndex].FindControl("lbtnUpdate") as LinkButton;
    LinkButton lbtnCancel = gvViewAdmins.Rows[e.NewEditIndex].FindControl("lbtnCancel") as LinkButton;
    LinkButton lbtnEdit = gvViewAdmins.Rows[e.NewEditIndex].FindControl("lbtnEdit") as LinkButton;

    lbtnUpdate.Visible = true;
    lbtnCancel.Visible = true;
    lbtnEdit.Visible = false;

}

What is wrong in my code?

  • 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-01T09:18:52+00:00Added an answer on June 1, 2026 at 9:18 am

    After looking at your code, It seems that, you are not using gridview’s default edit functionality. You are just setting controls visible property on and off.

    Better way is, Define ItemTemplate and Edit Item Template Separately like,

    Markup:

    <asp:GridView ID="objGridView" runat="server" AutoGenerateColumns="false" onRowEditing="objGridView_RowEditing">
      <columns>
         <asp:TemplateField HeaderText="">
            <ItemTemplate>
              <asp:Label ID="lblEmailID" runat="server" Text='<%#Eval("<<EmailID Field>>")%>' />
            </ItemTemplate>
            <EditItemTemplate>
              <asp:TextBox ID="txtEmailID" runat="server" Text='<%#Eval("<<EmailID Field>>")%>'/>
            </EditItemTemplate>
         </asp:TemplateField>
      </columns>
    </asp:GridView>
    

    Code Behind:

    protected void objGridView_RowEditing(object sender, GridViewEditEventArgs e)
    {
      objGridView.EditIndex = e.NewEditIndex;
      <<BindGrid Again>>
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a data grid view ( say 5 columns ) . User has
I have a editable gridview. When I click on edit button corresponding to a
I have an editable DataGridView with SelectionMode set to FullRowSelect (so the whole row
I have a simple table view which is editable. All I need the user
I have a UITable View with a textfield that is editable right on the
Hopefully this is a quick one! I have an editable grid using 'clientSide' (local)
I have editable dropdown list box on jquery grid, if I am not selecting
I have a grid view which contains some sequence numbers. Each column needs to
I have jqGrid with enabled EDIT, DELETE, ADD and VIEW , Now my problem
I have an editable grid that uses a store. I want to insert a

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.