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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:02:03+00:00 2026-05-23T04:02:03+00:00

I am trying to get an application to allow a user to select something

  • 0

I am trying to get an application to allow a user to select something for a number rows and then do something on the server side once the user submits the form. The problem I’m having is that if I reload the table, I just get the default values back and if I don’t, the table is empty. Here is the code:

    <asp:Table ID="tbl" runat="server">
        <asp:TableRow>
            <asp:TableHeaderCell>Question</asp:TableHeaderCell>
            <asp:TableHeaderCell>Answer</asp:TableHeaderCell>
        </asp:TableRow>
    </asp:Table>

c#:

    protected System.Web.UI.WebControls.Table tbl1;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            init_tbl();
        }
    }
    protected void init_tbl()
    {
        tbl1.BorderWidth = 1;
        TableRow tr = new TableRow();
        tc = new TableCell();
        tc.Text = "text";
        tc.BorderWidth = 1;
        tr.Cells.Add(tc);

    ddl = new DropDownList();
    ddl.ID = "r" + index;
    ddl.Attributes["runat"] = "server";

    ListItem item;
    for (int i = 1; i <= 10; i++)
    {
         item = new ListItem();
         item.Text = i.ToString();
         item.Value = i.ToString();
         if (i.ToString().Equals(r.Trim()))
         {
             item.Selected = true;
          }
          ddl.Items.Add(item);
      }      
      list.Add(ddl);
      tc.Controls.Add(ddl);

      tc.ID = "tblr" + index;
      tr.Cells.Add(tc);

      tbl1.Rows.Add(tr);
    }
  • 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-23T04:02:03+00:00Added an answer on May 23, 2026 at 4:02 am

    your problem is with the convoluted way asp.net deals with dynamic controls, you need to create the dynamic control on page init, before the view state is set so state of the controls is maintained on the post, see this article http://geekswithblogs.net/shahed/archive/2008/06/26/123391.aspx.

    You should definatley look at the gridview or at the very least one of the repeater controls.

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

Sidebar

Related Questions

Trying to get an ASP application deployed; it worked for a while but then
I've been trying desperately to get my application (15 C# dlls and 1 C++/CLI
We're trying to get SMB volume listings in our OS X application, and have
I'm trying to get tags working in my rails application and want to use
I am trying to get a description in a XUL application to wrap, even
I am trying to get the DB2 data provider from a 32-bit .Net application
I'm trying to get the MVCToolkit working with an ASP.NET MVC Beta application and
I'm trying to get a bare-bones example of logging going in my ASP.NET application.
Alright, I'm trying to get arguments to work properly with a small test application.
Trying to create a QtRuby application, I get the following error: /usr/lib64/ruby/site_ruby/1.8/Qt/qtruby4.rb:2144: [BUG] Segmentation

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.