Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 118
  • Last Modified:

ASP.net VB.net Add TextBox to specific cell in table

Hi

What VB.net code would I use to do this?

Thanks
0
Murray Brown
Asked:
Murray Brown
  • 2
1 Solution
 
Ramkisan JagtapLead DeveloperCommented:
can you please explain little bit more about your requirement?
0
 
Ramkisan JagtapLead DeveloperCommented:
private void GenerateTable(int colsCount, int rowsCount){

        //Creat the Table and Add it to the Page
        Table table = new Table();
        table.ID = "Table1";
        Page.Form.Controls.Add(table);

        // Now iterate through the table and add your controls 
        for (int i = 0; i < rowsCount; i++){
            TableRow row = new TableRow();
            for (int j = 0; j < colsCount; j++){
                TableCell cell = new TableCell();

if(yourspecificcondition)
{
//if condition is not satisfied it will add empty cell to your table row in code below
                TextBox tb = new TextBox();

                // Set a unique ID for each TextBox added
                tb.ID = "TextBoxRow_" + i + "Col_" + j;
                // Add the control to the TableCell
                cell.Controls.Add(tb);
}

                // Add the TableCell to the TableRow
                row.Cells.Add(cell);
            }

            // Add the TableRow to the Table
            table.Rows.Add(row);
        }
}

Open in new window

0
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks very much
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now