Click here to Skip to main content
15,904,023 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
string Answer = objEvaluationQuestion.PossibleAnswers; 
                string[] PossibleAnswer=Answer.ToString().Split(',');
                string a = "";

                for (int item=0; item < PossibleAnswer.Length;item++ )
                {
                    row = new TableRow();
                    cell = new TableCell();
                    TextBox tx = new TextBox();
                    tx.ID = "box" + item.ToString();
                    cell.Controls.Add(tx);
                    row.Cells.Add(cell);
                    table.Rows.Add(row);
                    //a..Add(table);
                    a = item + "," + a;
                }
                

                txtPossibleAnswers.Text = objEvaluationQuestion.PossibleAnswers;




this is my code
at this point
C#
string[] PossibleAnswer=Answer.ToString().Split(',');

i got the value 5 (for example)

C#
for (int item=0; item < PossibleAnswer.Length;item++ )
                {
                    row = new TableRow();
                    cell = new TableCell();
                    TextBox tx = new TextBox();
                    tx.ID = "box" + item.ToString();
                    cell.Controls.Add(tx);
                    row.Cells.Add(cell);
                    table.Rows.Add(row);
                    //a..Add(table);
                    a = item + "," + a;
                }


using this loop i want to create the text boxes dynamically.

and show the value for my database which i am getting here

C#
txtPossibleAnswers.Text = objEvaluationQuestion.PossibleAnswers;  


to my user.

help me plz
Posted
Comments
johannesnestler 8-Mar-13 5:10am    
Seems to be a simple task, I want to help, but I don't understand what your problem is... Can you explain it "better"? Should the TextBoxes be in a Datagrid or just on a "container" (GroupBox/Panel) on your Form (or WPF-Window, ...)?

1 solution

Hi,
You are adding text boxes to to your table row dynamically, but you are not setting the value to text box.
Perhaps you should add the text to the text box as well.
C#
for (int item=0; item < PossibleAnswer.Length;item++ )
{
    row = new TableRow();
    cell = new TableCell();
    TextBox tx = new TextBox();
    tx.ID = "box" + item.ToString();
    tx.Text = item.ToString();
    cell.Controls.Add(tx);
    row.Cells.Add(cell);
    table.Rows.Add(row);
    //a..Add(table);
    a = item + "," + a;
}


Hope this helps.

Regards
Jegan
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900