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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:01:38+00:00 2026-05-27T10:01:38+00:00

I have a function with the following code that binds a table dynamically. I

  • 0

I have a function with the following code that binds a table dynamically. I am calling this function in the page load. After this method is called the table contains three columns: A checkbox, label, and textbox.

I also have a button control. When this button is clicked I am checking for the checked checkboxes inside the table and then inserting data into the database corresponding to checked checkbox.

The problem is that it is not storing the checked state of the checkbox when the button is clicked as the button click also calls page load, which calls the function below and hence all of the elements in the table are recreated.

I cant use Page.IsPostBack here because the table should be loaded when the button is clicked. If I write the below code inside if(!Page.IsPostBack) then on button click it is not finding any rows in the table

try
{
    ManageVIN objMngVin = new ManageVIN();
    DataTable tblVins = objMngVin.MyFunction(clientCode);
    if (tblAssociateFleet.Rows.Count > 1)
    {
        for (int i = 1; i <= tblAssociateFleet.Rows.Count - 1; i++)
        {
            tblAssociateFleet.Rows[i].Cells.Clear();
        }
    }
    if (tblVins != null && tblVins.Rows.Count > 0)
    {
        foreach (DataRow dr in tblVins.Rows)
        {
            HtmlTableRow tblRow = new HtmlTableRow();
            tblRow.Attributes.Add("class", "tblrow");
            HtmlTableCell tblCell1 = new HtmlTableCell();
            CheckBox chk = new CheckBox();
            chk.CssClass = "selctChk";
            if (!Page.IsPostBack)
            {
                chk.Checked = false;
            }
            tblCell1.Controls.Add(chk);
            HtmlTableCell tableCelll2 = new HtmlTableCell();
            Label lblVinVlaue = new Label();
            lblVinVlaue.Text = Convert.ToString(dr["VIN"]);
            tableCelll2.Controls.Add(lblVinVlaue);
            HtmlTableCell tableCell3 = new HtmlTableCell();
            TextBox txtVinVal = new TextBox();
            txtVinVal.CssClass = "textEntry";
            tableCell3.Controls.Add(txtVinVal);
            tblRow.Cells.Add(tblCell1);
            tblRow.Cells.Add(tableCelll2);
            tblRow.Cells.Add(tableCell3);
            tblAssociateFleet.Rows.Add(tblRow);
        }
    }
}

How can I deal with this problem?

  • 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-05-27T10:01:39+00:00Added an answer on May 27, 2026 at 10:01 am

    You should do this in the Init or PreInit life cycle. PreInit is the preferred place for this according to MS. If you take a look at the ASP.NET page life cycle Load is a bit too late (specifically missing IPostBackDataHandler.LoadPostData which processes postback data of your checkbox clicks).

    Also, this is similiar to this stack overflow question.

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

Sidebar

Related Questions

I have a function that does the following: binds all images on the page
I have the following code that works on Firefox and Chrome $("#adicionarItem").click(function(){ $.ajax({ type:
I have the following code: $(document).ready(function(){ $(.yearInner).hide(); $(.year, this).hover( function () { $(.yearInner, this).slideToggle();
Let say I have the following code $(p).bind(click, function(){ alert( $(this).text() ); }); When
I have the following code: function Session(name, index) { this.Messages = []; this.Name =
The following code waits for data over UDP. I have a test function that
I have the following code: initialize: function() { _.bindAll(this); var callBack = function(res) {
Say I have the following code: function One() {} One.prototype.x = undefined; function Two()
Inside my template function I have the following code: TypeName myFunction() { TypeName result;
I have the following code in my .Zshrc function google; { $VIEW http://www.google.com/search?q='url-encode ${(j:

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.