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. Advertising

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. Gandalf
    Replies:
    12
    Views:
    556
    Gandalf
    Aug 1, 2003
  2. Rob T

    Hidden Texbox

    Rob T, Jun 10, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    10,538
    Sharon Tal
    Jun 10, 2004
  3. David

    width of texbox in editItem

    David, Jan 25, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    370
    David
    Jan 25, 2005
  4. =?Utf-8?B?RGVuaXNl?=

    Updating a texbox with Javascript

    =?Utf-8?B?RGVuaXNl?=, Mar 1, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    526
    =?Utf-8?B?RGVuaXNl?=
    Mar 1, 2005
  5. Yog
    Replies:
    0
    Views:
    1,590
Loading...

Share This Page