This is a migrated thread and some comments may be shown as answers.

Cast error

1 Answer 41 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Eva
Top achievements
Rank 1
Eva asked on 17 May 2011, 11:41 PM
I am getting the following cast error,
Cannot cast 'RadPanelBar1.FindItemByValue("QuickSearch").FindControl("txtFirstName")' (which has an actual type of 'Telerik.Web.UI.RadTextBox') to 'System.Web.UI.WebControls.TextBox'

 

protected void imSearch_Click(object sender, EventArgs e)

 

 

{

 

 

TextBox txtFirstName = (TextBox)RadPanelBar1.FindItemByValue("QuickSearch").FindControl("txtFirstName");

 

 

 

}

 

<telerik:RadPanelBar runat="server" ID="RadPanelBar1" Width="100%" ExpandMode="SingleExpandedItem" Skin="Windows7" >

 

 

<Items>

 

 

<telerik:RadPanelItem Text="Quick Search" Expanded="True" runat="server" >

 

 

<Items>

 

 

<telerik:RadPanelItem runat="server" Value="QuickSearch" BorderColor="Red" >

 

 

<ItemTemplate>

 

 

 

<asp:Label ID="lblSearch" style="text-align:center" runat="server" Text="First Name:" Font-Bold="True" />

 

 

 

<telerik:RadTextBox ID="txtFirstName" runat="server" EmptyMessage="Search First Name" Skin="WebBlue" Width="130px"/>

 

Can anybody tell me what I'm missing.

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 18 May 2011, 06:39 AM
Hello Eva,

Since you are using the RadTextBox, you need to cast it as RadTextBox not as TextBox.
C#:
protected void Button1_Click(object sender, EventArgs e)
   {
       RadTextBox txtFirstName = (RadTextBox)RadPanelBarContratti.FindItemByValue("QuickSearch").FindControl("txtFirstName");
      
   }

Thanks,
Shinu.
Tags
PanelBar
Asked by
Eva
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or