I'm using response.writefile("thisfile.inc") on an .aspx web page.
"thisfile.inc" contains a table and a bunch of labels like this: <asp:Label ID="label1" runat="server" Text="" />
On page load, after I've retrieved the data, I'm trying to put text in those labels.
Coming up with error:
Object reference not set to an instance of an object.
NullReferenceException: Object reference not set to an instance of an object.
Here the code behind
Dim lbl1 As Label
lbl1 = DirectCast(FindControl("label1"), Label)
lbl1.Text = Row("xNames").ToString
I'm creating several reports that the some of the same pages.
Each report has a big long SQL string call that pulls data from 7 different tables. All the reports don't need the same data.
Instead of duplicating coding to create the common pages on the report, I'm trying to include them.
This way I can pull 1 set of data with 1 call and not several for each report.
I tried creating usercontrols but the same problem happens.
I read someplace where you can't use findcontrol on a label. Is this true? Is there an alternative?
Is there a better way to do this?