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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:08:26+00:00 2026-06-18T06:08:26+00:00

I have a gridview with some custom templates: <asp:GridView ID=gvGroups runat=server AutoGenerateColumns=False CssClass=table table-hover

  • 0

I have a gridview with some custom templates:

 <asp:GridView ID="gvGroups" runat="server" AutoGenerateColumns="False"
     CssClass="table table-hover table-striped" GridLines="None" >
        <Columns>
            <asp:BoundField DataField="GroupDescription" HeaderText="Name" ReadOnly="True" 
                SortExpression="GroupDescription" />
            <asp:TemplateField HeaderText="Administrator">
                <ItemTemplate>
                    <asp:CheckBox ID="cbAdmin" runat="server" 
                    Checked='<%# Boolean.Parse((Boolean)Eval("IsReadOnly") ? "True" : "False") ? false : true %>'/>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Remove">
                <ItemTemplate>
                    <asp:CheckBox ID="cbRemove" runat="server" />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="ID" SortExpression="GroupID" Visible="False">
                <ItemTemplate>
                    <asp:Label ID="lblID" runat="server" Text='<%# Bind("GroupID") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>

I then have a button that I click and that is supposed to change group administration and remove groups that are checked.

Here is the button code:

  protected void btnSave_Click(object sender, EventArgs e)
        {
            foreach (GridViewRow gvr in gvGroups.Rows)
            {
                CheckBox cbAdmin = (CheckBox)gvr.FindControl("cbAdmin");
                CheckBox cbRemove = (CheckBox)gvr.FindControl("cbRemove");
                Label lblID = (Label)gvr.FindControl("lblID");
                int id;
                bool idValid = int.TryParse(lblID.Text,out id);
                bool isReadOnly = !cbAdmin.Checked;


                if (idValid)
                {
                    Group g = SecurityManager.GetGroup(id);

                    if (g.IsReadOnly != isReadOnly)
                    {
                        bool updateSuccess = SecurityManager.ChangeGroupPermissions(id, isReadOnly);
                    }

                    if (cbRemove.Checked)
                    {
                        bool removeEmpSuccess = SecurityManager.RemoveEmployeesFromGroup(id);
                        bool removeSuccess = SecurityManager.RemoveGroup(id);
                    }
                }
            }
        }

I used the debugger and even when I uncheck admin on all groups, when I look at cbAdmin.Checked, it is still true, which is the same value it started with, thus nothing ever happens.

What could be the problem? Why am I not seeing the updated values on the button postback?

Thanks

  • 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-18T06:08:28+00:00Added an answer on June 18, 2026 at 6:08 am

    You have to call GridView#DataBind() within if(!IsPostBack){ }

    Also you need to set AutoPostBack property of the textboxes to “true”

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

Sidebar

Related Questions

Using ASP.NET VB, I have a form with some text boxes and a Gridview.
i have a GridView bound to a DataView. Some columns in the DataView's table
I have asp.net page where I am using a gridView with custom paging and
I have an android gridview which i'm using some custom scrolling going on in,
I have some of these events in my gridview custom coded. But the real
I have a gridview with some imagebuttons, each of which kicks off a report
Need some help to solve this. I have a gridview and inside the gridview
Background: I have a ListView / GridView with several columns. In some situations, only
Need some help with DataFormatString in GridView. I have a Double value that needs
I'm working on some code which fills a GridView full of images that have

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.