Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Problem finding control in EditItemTemplate of FormView

Posted on 2007-11-13
Last Modified: 2013-11-07
Dear Experts,

I'm having some trouble finding a control within the EditItemTemplate of a formview.

I have listed my code below and how I'm trying to find the control.

Any help would be greatly appreciated.


My FormView...



    <legend><asp:Image ImageUrl="~/img/pt.gif" ID="Image3" runat="server" /> Select Account(s)</legend><asp:Label ID="Label1" Font-size="Large" Font-Bold="true" runat="server" Text=""></asp:Label>

   <asp:Panel ID="Panel2" runat="server" CssClass="modalPopup" Style="display: none" Width="233px">

   <br />

   <asp:Panel ID="Panel99" runat="server" CssClass="Modal" Style="display: none" Width="233px">


To add a control to found panel...

  Dim Panel1x As Panel = FormView1.FindControl("Panel99")
  Dim Label33 As New Label
  Label33.Text = " "
  Label33.Font.Bold = True

Object reference...
Question by:nkewney
LVL 22

Accepted Solution

RedKelvin earned 500 total points
ID: 20276300
Try using

Dim Panel1x As Panel = CType(FormView1.FindControl("Panel99"), Panel)

or from within a grid event such as "DeleteCommand"

Dim Panel1x As Panel = CType(e.Item.FindControl("Panel99"), Panel)
LVL 16

Expert Comment

ID: 20276478
Where are you calling the code?  The problem could be that the formview isn't actually in the right mode at the time you call the code.  Thus it cannot find the panel because it does not yet exist.

Double check that:   FormView1.CurrentMode = FormViewMode.Edit:  

If not, you may need to call:  FormView1.ChangeMode(FormViewMode.Edit)


Author Closing Comment

ID: 31409123
Thanks for this.


Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question