Dynamic Textbox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am adding a bunch of textboxs dyanmically as shown below

TextBox tb = new TextBox();
tb.ID = DR.GetName(y).ToString(); //Last_Name
tb.Text = DR[y].ToString();
tb.Width = 200;
objCell2.Controls.Add(tb);

but when i try to access the text property
sql += "Last_Name = '" + Last_Name.Text + "', ";

I get the error
c:\inetpub\wwwroot\LRUpdate\Default.aspx.cs(253): The type or namespace name 'Last_Name' could not be found (are you missing a using directive or an assembly reference?)

What am i doing wrong?

Thanks
~Thomas
 
You didn't declare it... make sure that Last_Name is properly declared.
Also when creating controls dynamically, make sure they are recreated before
controls are rendered, otherwise you won't get a value

--
Abdellah Elamiri
..net Developer
Efficacy through simplicity
Thomas said:
I am adding a bunch of textboxs dyanmically as shown below

TextBox tb = new TextBox();
tb.ID = DR.GetName(y).ToString(); //Last_Name
tb.Text = DR[y].ToString();
tb.Width = 200;
objCell2.Controls.Add(tb);

but when i try to access the text property
sql += "Last_Name = '" + Last_Name.Text + "', ";

I get the error
c:\inetpub\wwwroot\LRUpdate\Default.aspx.cs(253): The type or namespace
name 'Last_Name' could not be found (are you missing a using directive or an
assembly reference?)
 
First of all Last_Name has to be declared... where did you declare
Last_Name?

--
Abdellah Elamiri
..net Developer
Efficacy through simplicity
Thomas said:
I understand what you mean, but i don't realy know how to implement what
you are saying, can you please provide an example.
Thanks

A. Elamiri said:
You didn't declare it... make sure that Last_Name is properly declared.
Also when creating controls dynamically, make sure they are recreated before
controls are rendered, otherwise you won't get a value

--
Abdellah Elamiri
..net Developer
Efficacy through simplicity
Thomas said:
I am adding a bunch of textboxs dyanmically as shown below

TextBox tb = new TextBox();
tb.ID = DR.GetName(y).ToString(); //Last_Name
tb.Text = DR[y].ToString();
tb.Width = 200;
objCell2.Controls.Add(tb);

but when i try to access the text property
sql += "Last_Name = '" + Last_Name.Text + "', ";

I get the error
c:\inetpub\wwwroot\LRUpdate\Default.aspx.cs(253): The type or
namespace
name 'Last_Name' could not be found (are you missing a using directive or an
assembly reference?)
What am i doing wrong?

Thanks
~Thomas
 
That's not going to work

you need to have something like TextBox Last_Name; because you can use it
that way. You also have to make sure you set Last_Name before the controls
are rendered.

--
Abdellah Elamiri
..net Developer
Efficacy through simplicity
Thomas said:
it is declared here

TextBox tb = new TextBox();
tb.ID = DR.GetName(y).ToString(); // < --Last_Name
actually reads
tb.ID = "Last_Name";
tb.Text = DR[y].ToString();
tb.Width = 200;
objCell2.Controls.Add(tb);



A. Elamiri said:
First of all Last_Name has to be declared... where did you declare
Last_Name?

--
Abdellah Elamiri
..net Developer
Efficacy through simplicity
Thomas said:
I understand what you mean, but i don't realy know how to implement
what
you are saying, can you please provide an example.
Thanks

:

You didn't declare it... make sure that Last_Name is properly declared.
Also when creating controls dynamically, make sure they are
recreated
before
controls are rendered, otherwise you won't get a value

--
Abdellah Elamiri
..net Developer
Efficacy through simplicity
I am adding a bunch of textboxs dyanmically as shown below

TextBox tb = new TextBox();
tb.ID = DR.GetName(y).ToString(); //Last_Name
tb.Text = DR[y].ToString();
tb.Width = 200;
objCell2.Controls.Add(tb);

but when i try to access the text property
sql += "Last_Name = '" + Last_Name.Text + "', ";

I get the error
c:\inetpub\wwwroot\LRUpdate\Default.aspx.cs(253): The type or namespace
name 'Last_Name' could not be found (are you missing a using
directive
or an
assembly reference?)

What am i doing wrong?

Thanks
~Thomas
 
Check out this article, it should help you accomplish what you want
http://support.microsoft.com:80/support/kb/articles/q317/5/15.asp&NoWebContent=1

--
Abdellah Elamiri
..net Developer
Efficacy through simplicity
Thomas said:
then i'm really confused. How do i generate a textbox dynamically?
I don't know how many textbox's there will be or what they are called.

A. Elamiri said:
That's not going to work

you need to have something like TextBox Last_Name; because you can use it
that way. You also have to make sure you set Last_Name before the controls
are rendered.

--
Abdellah Elamiri
..net Developer
Efficacy through simplicity
Thomas said:
it is declared here

TextBox tb = new TextBox();
tb.ID = DR.GetName(y).ToString(); // < --Last_Name
actually reads
tb.ID = "Last_Name";
tb.Text = DR[y].ToString();
tb.Width = 200;
objCell2.Controls.Add(tb);



:

First of all Last_Name has to be declared... where did you declare
Last_Name?

--
Abdellah Elamiri
..net Developer
Efficacy through simplicity
I understand what you mean, but i don't realy know how to
implement
what
you are saying, can you please provide an example.

Thanks

:

You didn't declare it... make sure that Last_Name is properly declared.
Also when creating controls dynamically, make sure they are recreated
before
controls are rendered, otherwise you won't get a value

--
Abdellah Elamiri
..net Developer
Efficacy through simplicity
I am adding a bunch of textboxs dyanmically as shown below

TextBox tb = new TextBox();
tb.ID = DR.GetName(y).ToString(); //Last_Name
tb.Text = DR[y].ToString();
tb.Width = 200;
objCell2.Controls.Add(tb);

but when i try to access the text property
sql += "Last_Name = '" + Last_Name.Text + "', ";

I get the error
c:\inetpub\wwwroot\LRUpdate\Default.aspx.cs(253): The type or
namespace
name 'Last_Name' could not be found (are you missing a using directive
or an
assembly reference?)

What am i doing wrong?

Thanks
~Thomas
 
Back
Top