Setting Textbox Properties

Discussion in 'ASP .Net' started by Will Lastname, Sep 27, 2005.

  1. 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.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?
    Will Lastname, Sep 27, 2005
    1. Advertisements

  2. Will Lastname

    Rob Schieber Guest

    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.
    Rob Schieber, Sep 27, 2005
    1. Advertisements

  3. Thanks for the reply Rob. I will give this a whirl.
    Will Chamberlain, Sep 27, 2005
  4. Will Lastname

    Rob Schieber Guest

    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...
    Rob Schieber, Sep 27, 2005
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.