Add TextBox to specific cell in table


What code would I use to do this?

Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAsked:
Who is Participating?
Ramkisan JagtapConnect With a Mentor Lead DeveloperCommented:
private void GenerateTable(int colsCount, int rowsCount){

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

        // 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 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

                // Add the TableCell to the TableRow

            // Add the TableRow to the Table

Open in new window

Ramkisan JagtapLead DeveloperCommented:
can you please explain little bit more about your requirement?
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks very much
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.