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

The Archive Base Latest Questions

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

I have added control by if (e.Row.RowType == DataControlRowType.DataRow) { CheckBox chk = new

  • 0

I have added control by

    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        CheckBox chk = new CheckBox();
        chk.EnableViewState = true;
        chk.Enabled = true;
        chk.ID = "chkb";


        DataRowView dr = (DataRowView)e.Row.DataItem;
        chk.Checked = (dr[0].ToString() == "true");


        e.Row.Cells[1].Controls.Add(chk);
        e.Row.TableSection = TableRowSection.TableBody;
    }

and trying to find by

     if (GridView2.Rows.Count>0)
    {
        foreach (GridViewRow row in GridView2.Rows)
        {
            CheckBox cb =(CheckBox) GridView2.Rows[2].Cells[1].FindControl("chkb");
            if (cb != null && cb.Checked)
            {
                Response.Write("yest");
            }

        }
    }

But i cannot find it …
Actually my problem is that i need to create a dynamic list.. for that i am using gridview

  • 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-18T12:10:27+00:00Added an answer on June 18, 2026 at 12:10 pm

    You need to create dynamic controls on every postback since it is disposed at the end of the current life-cycle. But RowDataBound is just triggered when you databind the GridView what is done typically only if(!IsPostBack) (at the first time the page loads).

    You should create dynamic controls in RowCreated instead which is called on every postback. You can databind these controls then in RowDataBound if you want, since RowCreated is triggered first.

    protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            CheckBox chk = new CheckBox();
            chk.EnableViewState = true;
            chk.Enabled = true;
            chk.ID = "chkb";
            e.Row.Cells[1].Controls.Add(chk);
        }
    }
    
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            var chk = (CheckBox)e.Row.FindControl("chkb");
            // databind it here according to the DataSource in e.Row.DataItem
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to get the Grid.Row Grid.Column from the added control? Basically I have 16
I have added a FreeTextBox control in my page, which allows users to insert
I have created a wpf application into which I have added a user control
I have added an easy compound control which loads its layout from a XML
I have an Accordion control to which I have added a datagrid. The problem
I have a User Control added to a Canvas. In another area of the
I have a .NET PictureBox control added to a Windows.Forms.SplitterPanel. How do I do
I have several forms added to the pages of the tab control via tabcontrol.tabpages.controls.add
I have a custom control that can be added multiple times to a form.
I have a dropdown control, with some values I added in using the designer.

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.