CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2006
    Posts
    7

    Trouble with FormView

    Hi,

    I am learning ASP.Net.

    I have a project with a FormView.
    In the ItemTemplate there is a label called lblFY

    In the Page_PreRender event there is a call to...
    frmBudgetSummary.FindControl("lblFY")
    However, this does not find the control.

    What am I doing wrong?
    Is there a way to directly reference the label control without resorting to FindControl?
    What is the best way to reference a control in a FormView in code?

    Thanks,
    Scott

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto
    Posts
    805

    Re: Trouble with FormView

    you should put a breakpoint somewhere in the pre-render code and do a Watch on the frmBudgetSummary. It may have the control but you may need to drill down to it. using watch will let you know how many control levels you may have to drill down.

    For example the FormView may have one main control, and in that several different controls so you may need something like

    Code:
    frmBudgetSummary.Controls[0].FindControl("lblFY");
    using watch you can easily see how nested the label is.

    hth,
    mcm
    rate my posts!
    mcm

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured