Last post Aug 18, 2016 12:54 PM by Ken Carter
Aug 17, 2016 08:13 PM|Ken Carter|LINK
Or at least I think it does!
Here is what I have. I am working with VS2015 .Net 4.6.1. Working on a C# web forms site. One page is kicking my tail bad.
I have a FormView sitting in my aspx page bound to sqldatasource. This result in the auto-generation of:
protected global::System.Web.UI.WebControls.FormView ChangeFormFV;
... in the related sub design.cs file (it isn't commented out).
So I am puzzled why it is that in my aspx.cs file where this code exists:
Panel control = ChangeFormFV.Row.FindControl("ShortDescPnl") as Panel;
if (control != null)
control.Visible = true;
... Do I get redlined on ChangeFormFV indicating that The name 'ChangeFormFV' does not exist in the current context?'
I've gone back to review what is included regarding References on my project and I don't see anything that jumps out at me that might be missing. Here is what I have in References for the project:
So I am at a loss. I think my code has some issues that I need to fix after getting past this but need to resolve this issue first. Trying to set the visibility attribute of a panel inside of a FV and I have to do it in code behind. Only other way I could
figure to do it would be with a variable for each of the target panels that I manipulated from the code behind.. I played with that concept a bit and got no where fast.
Any thoughts would be greatly appreciated!
Aug 17, 2016 09:55 PM|PaulTheSmith|LINK
1) Sometimes the build system can get out of step with the state of files. Have you tried right clicking on the solution and select 'clean solution', then build again?
2) Always, always, always deal with the first error that is reported. Not the most interesting one or the last one or some random one. If there is a problem which is causing the generated code to not be compiled then your code-behind page will not find
some/all of the things declared in the uncompiled generated page.
If neither of these give any joy then it can sometimes be best to just recreate the page. That is, add a new page and build it again. If you are mega-cautious then you can add a control, reference it in the code-behind and then compile (ctrl-shift-b is
useful). Repeat until done or a problem turns up.
Aug 18, 2016 12:54 PM|Ken Carter|LINK
Thanks for the rebuilding of the page tip... That just saved my sanity. I was fairly sure I was doing everything right but was going crazy! I created a new page with a slightly different name then copy and pasted the aspx content from the original to the
new one. Then checked the design.cs to make sure that the global had been established as it should have for the FormView. After that I proceed rebuild the aspx.cs to where it was and wahah!! NO ERROR!