Solved

Problem finding control in EditItemTemplate of FormView

Posted on 2007-11-13
3
1,548 Views
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.

Thanks
Nick

My FormView...

<EditItemTemplate>

<fieldset>

    <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">

   
   </asp:Panel>
     
   <br />
   

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

==THIS IS THE PANEL==
       
   </asp:Panel>

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
  Panel1x.Controls.Add(Label33)

Object reference...
0
Comment
Question by:nkewney
[X]
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
3 Comments
 
LVL 22

Accepted Solution

by:
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)
0
 
LVL 16

Expert Comment

by:GreymanMSC
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)

0
 
LVL 1

Author Closing Comment

by:nkewney
ID: 31409123
Thanks for this.

NIck
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

738 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