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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:35:44+00:00 2026-05-24T08:35:44+00:00

OK So I have a web app with a dropdown field, a show button

  • 0

OK So I have a web app with a dropdown field, a show button and a gridview that i can edit. Page loads, I choose my dropdown value, page loads fine. When I go to click the edit button however, I have to click it twice in order to be able to edit or cancel (having issues with that also but thats a different issue)
Anyway, I want to be able to have one click on edit to bring up the update/cancel editmode. I’m new to C# Web apps so some insight would be helpful.

Thanks

My ASP

<asp:GridView ID="GridView1" runat="server" CssClass="styled" 
   OnRowEditing="TaskGridView_RowEditing"
   OnRowCancelingEdit="TaskGridView_RowCancelingEdit" 
   OnRowUpdating="TaskGridView_RowUpdating"   >
   <Columns>
        <asp:CommandField ShowEditButton="True" />
   </Columns>
</asp:GridView>

My C#

protected void TaskGridView_RowEditing(object sender, GridViewEditEventArgs e)
{

    //Set the edit index.
    GridView1.EditIndex = e.NewEditIndex;
    //Bind data to the GridView control.
   // BindData();


}

protected void TaskGridView_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
    //Reset the edit index.
    GridView1.EditIndex = -1;
    //Bind data to the GridView control.
    BindData();
    Image1.Visible = true;
    Image2.Visible = false;

}

protected void TaskGridView_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
    //Retrieve the table from the session object.
    System.Data.DataTable dt = (System.Data.DataTable)Session["EditDataPage"];

    //Update the values.
    GridViewRow row = GridView1.Rows[e.RowIndex];
   // dt.Rows[row.DataItemIndex]["QuoteNumber"] = ((TextBox)(row.Cells[1].Controls[0])).Text;
   // dt.Rows[row.DataItemIndex]["ItemNumber"] = ((TextBox)(row.Cells[2].Controls[0])).Text;
   //dt.Rows[row.DataItemIndex]["IsComplete"] = ((CheckBox)(row.Cells[3].Controls[0])).Checked;
   // dt.Rows[row.DataItemIndex]["Item"] = ((TextBox)(row.Cells[3].Controls[0])).Text;
   // dt.Rows[row.DataItemIndex]["Descp"] = ((TextBox)(row.Cells[4].Controls[0])).Text;
   // dt.Rows[row.DataItemIndex]["Route"] = ((TextBox)(row.Cells[5].Controls[0])).Text;
   // dt.Rows[row.DataItemIndex]["Unit"] = ((TextBox)(row.Cells[6].Controls[0])).Text;
   // dt.Rows[row.DataItemIndex]["IG"] = ((TextBox)(row.Cells[7].Controls[0])).Text;
   // dt.Rows[row.DataItemIndex]["EXTQTY"] = ((TextBox)(row.Cells[8].Controls[0])).Text;
  //  dt.Rows[row.DataItemIndex]["CSTCD"] = ((TextBox)(row.Cells[9].Controls[0])).Text;
  //  dt.Rows[row.DataItemIndex]["PCOST"] = ((TextBox)(row.Cells[10].Controls[0])).Text;
  //  dt.Rows[row.DataItemIndex]["SCOST"] = ((TextBox)(row.Cells[11].Controls[0])).Text;
  //  dt.Rows[row.DataItemIndex]["ACOST"] = ((TextBox)(row.Cells[12].Controls[0])).Text;
  //  dt.Rows[row.DataItemIndex]["TCOST"] = ((TextBox)(row.Cells[13].Controls[0])).Text;
  //  dt.Rows[row.DataItemIndex]["ICOST"] = ((TextBox)(row.Cells[14].Controls[0])).Text;
  //  dt.Rows[row.DataItemIndex]["BIZCODE"] = ((TextBox)(row.Cells[16].Controls[0])).Text;
 //   dt.Rows[row.DataItemIndex]["DeleteItem"] = ((TextBox)(row.Cells[17].Controls[0])).Text;

    //Reset the edit index.
    GridView1.EditIndex = -1;

    //Bind data to the GridView control.
    BindData();
}

private void BindData()
{

    GridView1.DataSource = Session["Sqldatasource1"];
    GridView1.DataBind();

  • 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-24T08:35:45+00:00Added an answer on May 24, 2026 at 8:35 am

    in the rowediting event you do need to set editindex and then databind. you need to do it in the other events too. see http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowediting.aspx

    GridView1.EditIndex = e.NewEditIndex;
    GridView1.DataBind();
    

    your control may disappear if you databind unnecessarily. make sure you only databind in page_load once.

    if(!Page.IsPostBack)
        GridView1.DataBind();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web app that only registered users can use, therefore I should
I have a web app for commercial property management that needs spreadsheet-like functionality for
I have a web app that is heavily loaded in javascript and css. First
I have a web app in production that is used for typical data entry,retrieval,
We have an web app that is talking to Netsuite via Netsuite's web services.
I have a web app which pulls in information via ajax after the page
I have used this tutorial from Google to build a web app that finds
I have a C#.Net MVC3 web app. There is and Edit View for my
I have this text input field on a web page. User types in item
need ask you about some help. I have web app running in Net 2.0.

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.