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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:20:26+00:00 2026-06-07T01:20:26+00:00

I have a gridview that contains a CheckBox. <asp:GridView ID=GridView1 runat=server AutoGenerateColumns=false OnRowCreated=GridView1_RowCreated BackColor=#F1EFC5

  • 0

I have a gridview that contains a CheckBox.

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" OnRowCreated="GridView1_RowCreated"
    BackColor="#F1EFC5" CssClass="SearchEveryWhere_Table" Width="500px">
    <HeaderStyle BackColor="#5391DD" ForeColor="White" />
    <Columns>
      <asp:BoundField DataField="CityCode" ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Middle" Visible="false">
            <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" CssClass="EntryCell hideElement" />
      </asp:BoundField>
      <asp:BoundField DataField="Switch" ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Middle"  Visible="false">
      <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" CssClass="EntryCell hideElement" />
      </asp:BoundField>
      <asp:BoundField DataField="Page_Number" ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Middle"  HeaderText="Page">
           <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" CssClass="EntryCell" />
      </asp:BoundField>
      <asp:BoundField DataField="Name" ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Middle"  HeaderText="Title">
            <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" CssClass="EntryCell" />
      </asp:BoundField>
      <asp:TemplateField HeaderText="Access">
          <ItemTemplate>
               <asp:CheckBox runat="server" AutoPostBack="true" OnCheckedChanged="chkStatus_OnCheckedChanged" Checked='<%# Convert.ToBoolean(Eval("Access")) %>' ID="chkStatus" ClientIDMode="Static" />
           </ItemTemplate>
           <HeaderStyle HorizontalAlign="Center" />
           <ItemStyle HorizontalAlign="Center" />
       </asp:TemplateField>
   </Columns>
 </asp:GridView>

I want change ID of this CheckBox to a value such this:

protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
    try
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            sp_GetPageAccess08_New_Result CurrentREcord = (sp_GetPageAccess08_New_Result)e.Row.DataItem;
            e.Row.Cells[4].FindControl("chkStatus").ID = "chkStatus_" + CurrentREcord.CityCode + "_" + CurrentREcord.Page_Number + "_" + CurrentREcord.Switch.ToString();
            if (CurrentREcord.Access == false)
            {
                e.Row.BackColor = System.Drawing.Color.FromArgb(252, 212, 243);
            }
        }
    }
    catch (Exception ex)
    {

    }
}

the problem is when I want to get ID I get chkStatus in chkStatus_OnCheckedChanged:

rotected void chkStatus_OnCheckedChanged(object sender, EventArgs e)
{
    try
    {
        CheckBox chk = sender as CheckBox;
        string ID = chk.ID;

How I can Change ID of chkStatus? If it’s impossible in how I can save that string in a property that can get in chkStatus_OnCheckedChanged?

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-07T01:20:28+00:00Added an answer on June 7, 2026 at 1:20 am

    Correction of my code

    in your OnRowDatabound add

    ((CheckBox)e.Row.Cells[4].FindControl("chkStatus")).Attributes.Add("MyData", string.Format("{0}_{1}_{2}", CurrentREcord.CityCode, CurrentREcord.Page_Number, CurrentREcord.Switch.ToString());
    

    in your checkbox check/uncheck event use this to get the data

    string data = chkStatus.Attributes["myData"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So - I have a checkbox <asp:CheckBox ID=chkOrder runat=server Visible='<%#IsCheckBoxVisible() %>' Checked=false OnCheckedChanged=chkOrder_CheckedChanged AutoPostBack=true
I have a VS2010 ASP.Net webform that contains a GridView. This GridView has ShowHeaderWhenEmpty=True
I have a gridview that contains user info and one of the columns is
I have a gridview that contains value of every rows read from a text
I have a simple gridview that contains a label in one of the rows.
I have a GridView. My GridView has a column that is contains an Options
I have ModalPopupExtender that contains a UserControl that basically consists of a GridView and
I have a user control that contains a GridView. The GridView has both a
I have an ambitious requirement for an asp.net 2.0 web page that contains a
I have a datalist that contains a gridview inside its itemtemplate. on the item-data_bound

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.