我試圖將值傳遞給數據源中的標籤,但它始終向我提供此錯誤。ASP:未將對象引用設置爲對象的實例
form1.aspx:
<asp:FormView ID="ProductsView" DataSourceID="ProductDataSource" DataKeyNames="Parking_ID"
runat="server" >
<ItemTemplate>
<div style="width: 200px; height: 200px; border: solid 10px white; background-position: center;
background-repeat: no-repeat; background-image: url('<%# Eval("Parking_ID", "images/{0}.bmp") %>');">
</div>
<asp:HiddenField Value='<%# Eval("Parking_Cost") %>' ID="hiddenPrice" runat="server" />
<asp:HiddenField Value='<%# Eval("Parking_Name") %>' ID="hiddenName" runat="server" />
<asp:HiddenField Value='<%# Eval("Parking_ID") %>' ID="HiddenField1" runat="server" />
</ItemTemplate>
</asp:FormView>
<asp:Label ID="lblName" runat="server" Text="TEST" CssClass="title" Style="font-size: 17px;
display: block;"></asp:Label>
<asp:Label ID="lblPrice" runat="server" Text="TEST" CssClass="title" Style="color: Red;
font-size: 12px;"></asp:Label>
<asp:Label ID="lbl_ID" runat="server" Text="" CssClass="title" Style="color: Red;
font-size: 12px;"></asp:Label>
<asp:SqlDataSource ID="ProductDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:mydatabaseConnectionString2 %>"
ProviderName="System.Data.SqlClient" SelectCommand="SELECT * FROM [Parking] WHERE ([Parking_ID] = @Parking_ID)">
<SelectParameters>
<asp:Parameter Name="Parking_ID" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
form1.aspx.vb:
lblName.Text = DirectCast(Me.ProductsView.FindControl("hiddenName"), HiddenField).Value
我使用vb.net腳本
任何想法?
問候。
可能的重複[什麼是.NET中的NullReferenceException?](http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-in-net) – 2011-05-01 22:30:27