Template column texbox - Unable to cast textarea as textbox

R

Randel

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
 

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,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top