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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:50:14+00:00 2026-06-01T02:50:14+00:00

I am dynamically creating a RadGrid and adding GridTemplateColumns to it. Those columns have

  • 0

I am dynamically creating a RadGrid and adding GridTemplateColumns to it. Those columns have textbox in them.
After binding datatable to the grid, after user makes changes to the textboxes and on clicking save button, I would like to access the textbox values. But I am stuck at getting hold of the textbox instance. I couldn’t even get hold of GridItems!
To add more complexity, my RadGrid is in a UserControl, which is in a (multi)view.
Heres the code.

    protected void Page_Init(object sender, EventArgs e)
    {
        DefineGridStructure();            
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (RadGrid1 != null && RadGrid1.Items.Count > 0)
        {
            string strtxt = ((TextBox)RadGrid1.Items[1]["ProductGroup1"].Controls[0]).Text;//For starters, load one control and check it's state
        }
    }
    private void DefineGridStructure()
    {
        RadGrid1 = new RadGrid();
        RadGrid1.AutoGenerateColumns = false;
        RadGrid1.ShowHeader = true;
        RadGrid1.NeedDataSource += RadGrid1_NeedDataSource;
        foreach(GridColumn qtyColumn in BuildGridQtyColumns(PaxColumnCount))
        {
            RadGrid1.MasterTableView.Columns.Add(qtyColumn);
        }
        //Add grid to page
        phRadGrid.Controls.Add(RadGrid1);
    }
    private List<GridColumn> BuildGridQtyColumns(int count)
    {
        List<GridColumn> qtyColumns = new List<GridColumn>();
        for (int i = 1; i <= count; i++)
        {
            string qtyColumnName = string.Format("ProductGroup{0}", i);
            GridTemplateColumn qtyColumn = new GridTemplateColumn();
            qtyColumn.ItemTemplate = new GridNumberTemplate(qtyColumnName);//Creates a textbox control
            qtyColumn.UniqueName = qtyColumnName;
            qtyColumn.HeaderText = "Qty";
            qtyColumn.HeaderStyle.Width = Unit.Pixel(60);
            qtyColumn.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;

            qtyColumns.Add(qtyColumn);
        }
        return qtyColumns;
    }

Since my control is in view, it’s Page_Init is called more than once for each action that involves this view.

  • 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-01T02:50:15+00:00Added an answer on June 1, 2026 at 2:50 am

    For a dynamically generated radgrid, it should be created in page_init method and viewstate for this grid will be restored for us automatically which we can get hold of in page_load method.

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

Sidebar

Related Questions

I have found code like this for dynamically creating a Grid and some columns:
I am dynamically creating textboxes using document.createElement('input') and adding a break between them using
I'm dynamically creating validation controls and adding them to an update panel. However the
I am dynamically creating some classes and I want them to have different docstrings.
I have a WPF ListView control for which I am dynamically creating columns. One
Using DTS I'm dynamically creating an access database. After the file is created (which
I am dynamically creating a table which I want to have clickable rows. When
I'm dynamically creating textfields in as3, and formatting them with the TextFormat class. I'm
I have an ASPX page that is dynamically creating a gridview from a database
I am dynamically creating a table that contains a textbox in each cell. The

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.