HighTechTalks DotNet Forums  

Template column texbox - Unable to cast textarea as textbox

ASP.net Data Grid Control microsoft.public.dotnet.framework.aspnet.datagridcontrol


Discuss Template column texbox - Unable to cast textarea as textbox in the ASP.net Data Grid Control forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Randel
 
Posts: n/a

Default Template column texbox - Unable to cast textarea as textbox - 02-28-2007 , 09:29 AM






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


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.