Setting Textbox Properties

W

Will Lastname

I am trying to manipulate the textbox properties in my datagrid for
when I fire the Edit/Update from the EditCommandColumn. I have set a
few attributes such as:

Dim tbPhone As TextBox = CType(e.Item.Cells(4).Controls(0), TextBox)

tbPhone.BorderStyle = BorderStyle.Solid
tbPhone.BorderWidth.Pixel(1)
tbPhone.Font.Name = "Tahoma"

When I run the application and click 'Edit' the attributes above are
not reflected in the textbox. They (textboxes) resort back to their
clunky default attributes.

Any suggestions?
 
R

Rob Schieber

Will said:
I am trying to manipulate the textbox properties in my datagrid for
when I fire the Edit/Update from the EditCommandColumn. I have set a
few attributes such as:

Dim tbPhone As TextBox = CType(e.Item.Cells(4).Controls(0), TextBox)

tbPhone.BorderStyle = BorderStyle.Solid
tbPhone.BorderWidth.Pixel(1)
tbPhone.Font.Name = "Tahoma"

When I run the application and click 'Edit' the attributes above are
not reflected in the textbox. They (textboxes) resort back to their
clunky default attributes.

Any suggestions?

My guess is that the attributes of the textbox are getting changed after
the textbox has already rendered. I would try applying the styles
before the textboxes render, such as in the OnItemDataBound event.
 
R

Rob Schieber

Will said:
Thanks for the reply Rob. I will give this a whirl.

No problem. One thing to remember when doing this is to make sure you
are using the right ItemType within the event.

void OnItemDataBound(object sender, DataGridItemEventArgs e)
{
if(e.ItemType == EditItem)
{
do stuff...
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,008
Latest member
HaroldDark

Latest Threads

Top