Link to home
Start Free TrialLog in
Avatar of noulouk
noulouk

asked on

Retrieve dynamically created TextBox value

Hi Experts,

I have created  a table dynamically with 1 textbox and 1 button:
private dynamicTable()
{
Table Mytable=new Table();
TableRow row1=new TableRow();
TableCell cell1=new TableCell();

TextBox mytextbox=new TextBox();
mytextbox.ID="mybox";
LinkButton mybutton=new LinkButton();
mybutton.ID="mybutton";
mybutton.Click+=new EventHandler(mybutton_Click);

cell1.Controls.Add(mytextbox);
cell1.Controls.Add(mybutton);
row1.Cells.Add(cell1);
Mytable.Rows.Add(row1);

PlaceHolder1.Controls.Add(MyTable);
}

private void mybutton_Click(object sender, EventArgs e)
        {
            Table Mytable=(Table)((LinkButton)sender).Parent;
            Response.Write(((TextBox)Mytable.FindControl("mybox")).Text);
        }

The problem is when I click the button, I can't retrieve my textbox value.
Where did I make a mistake ?

Thanks for your answers.
SOLUTION
Avatar of s_sansanwal
s_sansanwal

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial