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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:19:01+00:00 2026-05-16T18:19:01+00:00

The problem is: On postback, the table does not have the rows that were

  • 0

The problem is: On postback, the table does not have the rows that were dynamically created, the rowcount is 0.

  • Click on the button, it should detect the checked checkboxes within the table dynamically generated.
  • The table is made by code when the “day” is selected using the drop down list and “the starting date” is selected using the calender.

I know there’s a lot of code, but it’s the least I thought I had to post, so answerers can debug. Please note I have tried hard but cannot get the solution to this.

Here’s the code:

public partial class DaySelection : System.Web.UI.Page
{
    Table table1 = new Table();
    Button button1 = new Button();
    string the_id_checkbox;
    string the_id_label;
    //The need of the table ENDS
    DropDownList selectdays = new DropDownList();
    Label theselecteddate = new Label();
    Button extract_the_selected = new Button();
    Literal selected_values=new Literal();
    int number_of_row = -1;
    protected void Page_Load(object sender, EventArgs e)
    {
        CheckBox check_or_not = new CheckBox();
        try
        {
            selected_values.Text = "";
            form1.Controls.Remove(selected_values);
            form1.Page.Response.Write("inside try");
            for (int i = 0; i < table1.Rows.Count; i++)
            {
                Response.Write("inside for");
                the_id_checkbox = "checkmate" + i;
                the_id_label = "The_text" + i;
                check_or_not = (CheckBox)table1.Rows[i].FindControl(the_id_checkbox);
                if (check_or_not.Checked == true)
                {
                    form1.Page.Response.Write("inside if");
                    selected_values.Text = selected_values.Text + "<br /> " + check_or_not.Checked.ToString();
                    selected_values.Text = selected_values.Text + "  and the day is:  " + ((Label)table1.Rows[i].FindControl(the_id_label)).Text;
                }
                else
                {
                    Response.Write(" selection no detect");
                }
            }
            form1.Controls.AddAt(1, selected_values);
            Response.Write(selected_values.Text);
        }
        catch (NullReferenceException nn)
        {
            form1.Page.Response.Write("inside catch" + nn.Message.ToString() + nn.StackTrace);
        }
        extract_the_selected.Text = "Extract it";
        form1.Controls.AddAt(2,extract_the_selected);
        selectdays.AutoPostBack = true;
        ArrayList thedays = new ArrayList();
        thedays.Add("Monday" + DateTime.Now);
        thedays.Add("Tuesday");
        thedays.Add("Wednesday");
        thedays.Add("Thursday");
        thedays.Add("Friday");
        thedays.Add("Saturday");
        thedays.Add("Sunday");
        selectdays.DataSource = thedays;
        selectdays.DataBind();
        form1.Controls.AddAt(3,selectdays);
        Calendar1.SelectionChanged += new EventHandler(Calendar1_SelectionChanged);
    }

    void Calendar1_SelectionChanged(object sender, EventArgs e)
    {
        DateTime startdate;
        string month;
        month = Calendar1.SelectMonthText;
        startdate = Calendar1.SelectedDate;
        days_date(startdate);
    }

    void selectdays_SelectedIndexChanged(object sender, EventArgs e)
    {
        display_dates_of_day(DateTime.Parse("9-1-2010"), DateTime.Parse("9-30-2010"), selectdays.SelectedItem.Text);
    }

    public void days_date(DateTime startdate)
    {
        int noofdays;
        DateTime enddate = new DateTime();
        noofdays = DateTime.DaysInMonth(startdate.Year, startdate.Month) - 1;
        enddate = startdate.AddDays(noofdays);
        Response.Write("<br /> end date is  " + enddate);
        Response.Write("<br /> start date is " + startdate);
        display_dates_of_day( startdate, enddate, selectdays.SelectedItem.Text);
    }

    void display_dates_of_day(DateTime startDate, DateTime endDate, string selectedday)
    {
        int Count = 0;
        for (DateTime dt = startDate; dt <= endDate; dt = dt.AddDays(1.0))
        {
            if (dt.DayOfWeek.ToString() == selectedday)
            {
                table1.ID = "table1";
                number_of_row = number_of_row + 1;
                string date = dt.Date.ToString("dd-MMMM-yyyy");
                for (int adding_rows = 0; adding_rows < 1; adding_rows++)
                {
                    TableRow table_row1 = new TableRow();
                    TableCell table_cell1 = new TableCell();
                    TableCell table_cell2 = new TableCell();
                    Label The_label = new Label();
                    CheckBox checkmate = new CheckBox();
                    The_label.Text = date + " (<---date)" + number_of_row;
                    the_id_checkbox = "checkmate" + number_of_row;
                    checkmate.ID = the_id_checkbox;
                    the_id_label = "The_text" + number_of_row;
                    The_label.ID = the_id_label;
                    table_cell2.Controls.Add(checkmate);
                    table_cell1.Controls.Add(The_label);
                    table_row1.Controls.AddAt(0, table_cell1);
                    table_row1.Controls.AddAt(1, table_cell2);
                    table1.Rows.Add(table_row1);
                }
                button1.Text = "click me to export the value";
                form1.Controls.Add(table1);
                form1.Controls.AddAt(1, selected_values);
                Count++;
            }
        }
        Response.Write("<br /> The count of days by traversing:  " + Count);
    }
}
  • 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-16T18:19:01+00:00Added an answer on May 16, 2026 at 6:19 pm

    The reason you’re seeing this seemingly “strange” behaviour is that you’re dynamically constructing the contents of Table1 and adding it to the pages .Controls collection only in the display_dates_of_day method, which is called by:

    • selectdays_SelectedIndexChanged
    • Calendar1_SelectionChanged (indirectly)

    This means that when your page is re-contructed on post-back, the controls don’t exist. If you “View Source” in your browser, you’ll find that after clicking the button to trigger a post-back you can’t find the string “Table1” in the markup, but if you do it after clicking on a date in the calendar, you can. That’s because in the “clicking the button” scenario, the control is never populated and added to the page

    I’d make a few suggestions to get your head round this and solve the problem:

    1. Start with a much simplified version of this to help you understand the asp.net page lifecycle and how it impacts on what you’re doing.
    2. Try to ensure your code adds as few controls as possible to the page dynamically as this makes things a lot simpler. i.e. Make Table1 a control that’s declared in the .aspx page.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 517k
  • Answers 517k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Use this formula: ="'" & A1 & "'" May 16, 2026 at 7:53 pm
  • Editorial Team
    Editorial Team added an answer Making a project manageable is really not the point of… May 16, 2026 at 7:53 pm
  • Editorial Team
    Editorial Team added an answer I found a work around: var datatable = createGoogleData(...); var… May 16, 2026 at 7:53 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

My problem is: I've got a table, dynamically created, fill with a lot of
rbnResubmission.Items.FindByValue(Yes).Attributes.Add(onclick, getCheckedRadioFieldResubmission(this)); rbnResubmission.Items.FindByValue(No).Attributes.Add(onclick, getCheckedRadioFieldResubmission(this)); So I have these click events for showing rows in
I have this page where in i have a ModalPopupExtender. Now the panel that
Does anyone know of any examples or tutorials of an MVC view that shows
Sometimes I do despair when working with ASP.Net - another problem that shouldn't be!
I'm using adapter.InsertCommand to insert some data into a table. The only problem is
I have a masterpage with a sidebar that conatians an accordion control for site
My problem is that in the below code, the SelectedRow property returns nothing. I
I'm using the asp:Menu control on an ASP.NET 4.0 Webforms page with table-free rendering
I am having a weird issue in ASP.NET MVC with objects not being updated

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.