Template column texbox - Unable to cast textarea as textbox

Discussion in 'ASP .Net Datagrid Control' started by Randel, Feb 28, 2007.

  1. Randel

    Randel Guest

    Hi.

    I am using a template column in my datagrid that uses a multiline
    textbox (code follows)

    <asp:TemplateColumn HeaderText="pdRevisedOrIssued">
    <ItemTemplate>
    <asp:Label runat="server" Text='<%# DataBinder.Eval(Container,
    "DataItem.pdRevisedOrIssued") %>'>
    </asp:Label>
    </ItemTemplate>
    <EditItemTemplate>
    <asp:TextBox TextMode="MultiLine" runat="server" Text='<%#
    DataBinder.Eval(Container, "DataItem.pdRevisedOrIssued") %>'>
    </asp:TextBox>
    </EditItemTemplate>
    </asp:TemplateColumn>

    In my update code, I attempt to get the value of this control with the
    following code:

    string pdRevisedOrIssued = ((TextBox)e.Item.Cells[3].Controls[0]).Text

    The following error is thrown:
    System.InvalidCastException: Specified cast is not valid.

    Update works fine if textbox is not multiline. Unfortunately, I need
    the multiline capability.

    How do I obtain the value of the multiline textbox?

    Thanks for your help. I've been tearing my hair out over this. And
    I'm almost out of hair!!
    Randy
     
    Randel, Feb 28, 2007
    #1
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Yog
    Replies:
    0
    Views:
    1,723
  2. Deepak

    Accessing Textbox inside a Template column using javascript

    Deepak, Aug 6, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    241
    Saravana
    Aug 6, 2003
  3. Jodi
    Replies:
    0
    Views:
    258
  4. DAC
    Replies:
    0
    Views:
    216
  5. Tim

    Reading values from textbox in template column

    Tim, Oct 6, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    213
  6. Augustus
    Replies:
    1
    Views:
    629
    Ken Schaefer
    Sep 10, 2003
  7. Textarea Inside of a textarea

    , Feb 4, 2006, in forum: ASP General
    Replies:
    6
    Views:
    592
    Anthony Jones
    Feb 5, 2006
  8. Replies:
    1
    Views:
    519
    Bart Van der Donck
    Jul 4, 2007
Loading...