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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:08:45+00:00 2026-06-14T12:08:45+00:00

i have checkboxes in a grid. I am trying to access them from codebehind

  • 0

i have checkboxes in a grid. I am trying to access them from codebehind and get the data for checked /unchecked rows.But even after the checkboxes being checked I am getting them as Checked property as false only:

Aspx:

  <table width="100%">
            <asp:GridView ID="grdRequestsPending" runat="server" Width="100%" AutoGenerateColumns="false"
                BorderWidth="1px" BorderStyle="Solid" Style="margin-left: 0px" BorderColor="#ffcc00"
                RowStyle-BorderColor="#ffcc00" RowStyle-BorderStyle="Solid" RowStyle-BorderWidth="1px"
                GridLines="Both" DataKeyNames="ReqID,ApproverComments" On="grdRequestsPending_ItemDataBound" OnRowDataBound="grdRequestsPending_RowDataBound"
                OnPreRender="grdRequestsPending_PreRender">
                <RowStyle CssClass="dbGrid_Table_row" />
                <HeaderStyle CssClass="dbGrid_Table_Header" />
                <Columns>
                    <asp:TemplateField>
                        <HeaderTemplate>
                            <asp:Label ID="lblSelect" Text="Select All" runat="server"></asp:Label><br />
                            <asp:CheckBox ID="SelectAll" onclick="javascript:checkAllBoxes(this);" TextAlign="Left"
                                runat="server" />
                        </HeaderTemplate>
                        <ItemStyle Width="2%" />
                        <ItemTemplate>
                            <asp:CheckBox ID="chkReq" runat="server"/>
                        </ItemTemplate>
                        <ItemStyle HorizontalAlign="Center" Width="7%" />
                    </asp:TemplateField>
       </Columns>

But when I am checking these I am always getting them as false in code behind:

        protected void UpdateVMRequestStatusByCapSupLead(int StatusId)
    {
        try
        {

            DataTable dt = new DataTable();
            dt.Columns.Add("ReqId", typeof(int));
            dt.Columns.Add("StatusId", typeof(int));
            dt.Columns.Add("ModifiedBy", typeof(string));
            dt.Columns.Add("ModifiedDate", typeof(string));
            dt.Columns.Add("txtCommentSupLead", typeof(string));
            foreach (GridViewRow gr in grdRequestsPending.Rows)

            {
                CheckBox chk = (CheckBox)gr.FindControl("chkReq");

                if (chk.Checked)
                {
                    strReqId = strReqId + grdRequestsPending.DataKeys[gr.RowIndex].Value.ToString() + ',';

                    TextBox txtCommentSupLead = (TextBox)gr.FindControl("txtCommentSupLead");
                    dt.Rows.Add(dt.NewRow());
                    dt.Rows[dt.Rows.Count - 1]["ReqId"] = Convert.ToInt32(grdRequestsPending.DataKeys[gr.RowIndex].Value);
                    dt.Rows[dt.Rows.Count - 1]["StatusId"] = StatusId;
                    dt.Rows[dt.Rows.Count - 1]["ModifiedBy"] = Session["UserAccentureID"].ToString();
                    dt.Rows[dt.Rows.Count - 1]["txtCommentSupLead"] = txtCommentSupLead.Text;
                    dt.Rows[dt.Rows.Count - 1].AcceptChanges();
                    dt.Rows[dt.Rows.Count - 1].SetModified();
                }
            }

I am not getting the problem.I am gettign the control also correctly..

  • 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-14T12:08:46+00:00Added an answer on June 14, 2026 at 12:08 pm

    I assume that you’re always databinding your GridView and not only if(!Page.IsPostBack)....

    So put this in page_load

    protected void Page_Load(object sender, EventArgs e)
    {                        
        if(!Page.IsPostBack)
        {
            DataBindControls(); // like GridView etc.
        }
    }
    

    If you DataBind controls they will lose their changes and ViewState. Even events aren’t triggered then. So you should do that only on the first load if EnableViewState="true".

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

Sidebar

Related Questions

I've been trying to make it impossible to have two checkboxes checked at the
I have a listbox containing checkboxes. I want to get all the checkbox checked
I'm trying add vertical lines to my grid. I have found some examples but
I have a panel grid with various checkboxes. A checkbox is associated with a
I have two checkboxes. I need to check that at least one of them
So I have a TreeView that has heirarchical data templates that have CheckBoxes in
I have a Telerik RadGrid which is composed of rows of checkboxes and text.
So I have a grid view with checkboxes in it. This is the code
I am trying to use a Webgrid and I can get the data to
I have a WPF Data Grid bound to an observable collection, which is working

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.