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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:12:32+00:00 2026-06-13T18:12:32+00:00

I have a GridView with a button which sets all rows into edit mode

  • 0

I have a GridView with a button which sets all rows into edit mode (which is what I want). However I was wondering if there is a way to create a button that will update the whole gridview with my changes. Here is the code behind this.

<asp:GridView ID="gvUsers" runat="server" AutoGenerateColumns="False" 
        onrowcommand="gvUsers_RowDataBound">
    <Columns>


       <asp:TemplateField HeaderText="labelID" Visible="false">
            <ItemTemplate>
                <asp:Label ID="ID" runat="server" Text='<%# Eval("id") %>' />
            </ItemTemplate>
        </asp:TemplateField>

        <asp:TemplateField HeaderText="First Name">
            <ItemTemplate>
                <asp:Label ID="labelfirstname" Visible='<%# !(bool) IsInEditMode %>' runat="server" Text='<%# Eval("firstname") %>' />
                <asp:TextBox ID="txtFirstName" Visible='<%# IsInEditMode %>' runat="server" Text='<%# Eval("firstname") %>' />
            </ItemTemplate>
        </asp:TemplateField>
         <asp:TemplateField HeaderText="Last Name">
            <ItemTemplate>
                <asp:Label ID="labellastname" Visible='<%# !(bool) IsInEditMode %>' runat="server" Text='<%# Eval("lastname") %>' />
                <asp:TextBox ID="txtLastName" Visible='<%# IsInEditMode %>' runat="server" Text='<%# Eval("lastname") %>' />

            </ItemTemplate>
        </asp:TemplateField>


    </Columns>
    </asp:GridView>


<asp:Button ID="Button1" runat="server" Text="Edit Mode" onclick="Button1_Click1" />
<asp:Button ID="Button2" runat="server" Text="View Mode" onclick="Button2_Click1" />

And here is the c#

 private bool isEditMode = false;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            BindData();
        }
    }
    private void BindData()
    {

        string connectiongString = "Data Source=WSCJTCSQ1;Initial Catalog=LiquorStore;Integrated Security=True";
        SqlConnection myConnection = new SqlConnection(connectiongString);
        SqlDataAdapter ad = new SqlDataAdapter("SELECT id, firstname, lastname, nickname FROM Company", myConnection);
        DataSet ds = new DataSet();
        ad.Fill(ds);
        gvUsers.DataSource = ds;
        gvUsers.DataBind();

    }

    protected bool IsInEditMode
    {

        get { return this.isEditMode; }

        set { this.isEditMode = value; }

    }

    protected void gvUsers_RowDataBound(object sender, GridViewCommandEventArgs e)
    {

    }

    protected void Button1_Click1(object sender, EventArgs e)
    {
        isEditMode = true;

        BindData();
    }

    protected void Button2_Click1(object sender, EventArgs e)
    {

        isEditMode = false;

        BindData();
    }

Thank you in advance!!

  • 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-13T18:12:34+00:00Added an answer on June 13, 2026 at 6:12 pm

    You can iterate thru you rows and get values in a textbox for specific row

    foreach (GridViewRow row in gvUsers.Rows)
        {
            TextBox txtFirstName = row.FindControl("txtFirstName") as TextBox;
            TextBox txtLastName = row.FindControl("txtLastName") as TextBox;
    
            if (txtFirstName.Text!="" && txtLastName.Text!="")
            {
               // do what you need with values
            }
    
        }
    
    • 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 has normal Edit/Update button. However, my GV RowUpdating, RowEditing
I have a gridview which works fine. But it get into edit mode whenever
I have a Clear button which sets the gridview datasource to null and binds
want to have a Hyperlink-Button in a gridView in which I can display a
I have a gridview and I have a button on it.I want, if the
I have a gridview with multiple rows, each has a Update button and I
I have a button inside of a gridview's template field. Onclick i want to
I have GridView, which is not auto generating columns. In GridView there are 3
I have a gridview which shows all the information of the data table. I
I have a gridview in which itemtemplate contains hiddenfield.I have a button outside gridview.In

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.