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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:19:01+00:00 2026-06-08T12:19:01+00:00

I have a gridview which works fine. But it get into edit mode whenever

  • 0

I have a gridview which works fine. But it get into edit mode whenever command button is clicked. Is there anyway to stop this?

<asp:GridView id="grv_purchaseOrder" runat="server" AutoGenerateColumns="False" 
    onrowdatabound="grv_purchaseOrder_RowDataBound"  ShowFooter="True"
    EmptyDataText="No Purchase Order were found." DataKeyNames="purchaseOrderID" 
onrowcommand="grv_purchaseOrder_RowCommand" 
    onrowediting="grv_purchaseOrder_RowEditing">
    <Columns>
        <asp:TemplateField ShowHeader="False">
            <ItemTemplate>
                <asp:Button ID="but_purchaseOrderDetails" runat="server" CommandArgument='<%# DataBinder.Eval(Container, "RowIndex") %>'
                    CausesValidation="false" CommandName="edit" Text="Detail" />
            </ItemTemplate>
            <FooterTemplate>
                <asp:Button ID="but_newOrderDetails" runat="server" CausesValidation="false"  commandargument="0"
                    CommandName="new" Text="New" />
            </FooterTemplate>
        </asp:TemplateField>
        <asp:BoundField DataField="name" HeaderText="Name" />
        <asp:TemplateField HeaderText="Date">
            <ItemTemplate>
                <asp:Label ID="lbl_dateCreated" runat="server" Text='<%# Bind("dateCreated") %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:BoundField DataField="purchaseOrderStatus" HeaderText="Status" />
    </Columns>
</asp:GridView>

Specifically the but_newOrderDetails is putting the gridview in edit mode.

here is what’s inside the Row Command event handler:

        string currentCommand = e.CommandName;
        ClientScriptManager cs = Page.ClientScript;
        int rowIndex = int.Parse(e.CommandArgument.ToString());
        string purchaseOrderID = grv_purchaseOrder.DataKeys[rowIndex]["purchaseOrderID"].ToString();
        if (currentCommand == "edit" || currentCommand == "new") {
            cs.RegisterStartupScript(this.GetType(), "popupScript", "window.open('PurchaseOrderDetail.aspx?purchaseOrderID=" + purchaseOrderID + "','_blank');", true);
        }

I also try to put grv_purchaseOrder.EditIndex = -1; in rowEditing event, but it doesn’t do anything.

  • 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-08T12:19:02+00:00Added an answer on June 8, 2026 at 12:19 pm
    <asp:gridview id="GridView1" runat="server"> 
            <columns> 
                    <asp:templatefield> 
                            <itemtemplate> 
                                    <asp:linkbutton id="btnEdit" runat="server" commandname="Edit" enabled='<%# !(Eval("Status").ToString().Equals("Closed") || Eval("Status").ToString().Equals("Cancelled")) %>' 
    text="Edit" /> 
                            </itemtemplate> 
                    </asp:templatefield> 
            </columns> 
    </asp:gridview>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Gridview which binds to an ObjectDataSource (objStudentDetails). In edit/insert mode of
Hey guys, I have a GridView which is binded to SqlDataSource, everything works fine,
I have a gridview which has an asp image-button for deleting a row. I
I have the following which works fine: <%@ Page Language=C# AutoEventWireup=true CodeFile=Default2.aspx.cs Inherits=test_library_newsletter_Default2 %>
I have a gridview I created using this tutorial GridView Android , which works
I ran into the alignment issues with IE6.Code works just fine with IE8.I have
I've created a calendar which works fine, using a GridView which has an OnClickListener.
I have a GridView which is programatically filled from the DB (not a SqlDataSource
I have a GridView which I am populating by calling a method to return
I have a GridView which is databound to an XML Datasource. For one of

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.