ronhawker
06-16-2009, 09:46 AM
I have a detailview displaying data on a page and I want to display a field of that data in another place on the page. For example, I want to display the storephone value in more than one place on the page. How do I grab the data from the detailview and load it into say a label.
<div>
<asp:Label ID="Label3" runat="server" Text='<%# Eval("StorePhone") %>'></asp:Label>
</div>
This would work for a loaded dataset but is a detailview also a dataset or do I have to extract the data from the detailview outside of the detailview structure?
Also tried: Probably need a databind of the label to the detailview
<div>
<asp:Label ID="Label3" runat="server" Text='<%# DataBinder.Eval(DetailsView1.DataItem,"StoreBrands") %>'>test data</asp:Label>
</div>
</div>
<div class="Store_location_info_column_container">
<asp:DetailsView ID="DetailsView1" runat="server" Height="115px" Width="379px" AutoGenerateRows="False"
DataSourceID="SqlDataSource1" ForeColor="White" BorderStyle="None" HorizontalAlign="Left"
CaptionAlign="Left" GridLines="None">
<Fields>
<asp:BoundField DataField="StoreName" SortExpression="StoreName">
<ItemStyle Font-Size="30px" Font-Names="Arial" />
</asp:BoundField>
<asp:TemplateField SortExpression="StoreStreetAddress">
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("StoreStreetAddress") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField SortExpression="StoreCity">
<ItemTemplate>
<p>
</p>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("StoreCity") %>'></asp:Label>,
<asp:Label ID="Label4" runat="server" Text='<%# Eval("StoreState") %>'></asp:Label>
<asp:Label ID="Label5" runat="server" Text='<%# Eval("StoreZip") %>'></asp:Label>
<p>
</p>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="StorePhone" HeaderText="Phone:" SortExpression="StorePhone" />
<asp:BoundField DataField="StoreHours" HeaderText="Hours:" SortExpression="StoreHours" />
<asp:BoundField DataField="StoreEmail" HeaderText="Email:" SortExpression="StoreEmail" />
<asp:BoundField DataField="StoreBrands" HeaderText="Brands Carried:" SortExpression="StoreBrands" />
</Fields>
<RowStyle HorizontalAlign="Left" Font-Size="Medium" />
<EditRowStyle HorizontalAlign="Left" />
</asp:DetailsView>
</div>
<div>
<asp:Label ID="Label3" runat="server" Text='<%# Eval("StorePhone") %>'></asp:Label>
</div>
This would work for a loaded dataset but is a detailview also a dataset or do I have to extract the data from the detailview outside of the detailview structure?
Also tried: Probably need a databind of the label to the detailview
<div>
<asp:Label ID="Label3" runat="server" Text='<%# DataBinder.Eval(DetailsView1.DataItem,"StoreBrands") %>'>test data</asp:Label>
</div>
</div>
<div class="Store_location_info_column_container">
<asp:DetailsView ID="DetailsView1" runat="server" Height="115px" Width="379px" AutoGenerateRows="False"
DataSourceID="SqlDataSource1" ForeColor="White" BorderStyle="None" HorizontalAlign="Left"
CaptionAlign="Left" GridLines="None">
<Fields>
<asp:BoundField DataField="StoreName" SortExpression="StoreName">
<ItemStyle Font-Size="30px" Font-Names="Arial" />
</asp:BoundField>
<asp:TemplateField SortExpression="StoreStreetAddress">
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("StoreStreetAddress") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField SortExpression="StoreCity">
<ItemTemplate>
<p>
</p>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("StoreCity") %>'></asp:Label>,
<asp:Label ID="Label4" runat="server" Text='<%# Eval("StoreState") %>'></asp:Label>
<asp:Label ID="Label5" runat="server" Text='<%# Eval("StoreZip") %>'></asp:Label>
<p>
</p>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="StorePhone" HeaderText="Phone:" SortExpression="StorePhone" />
<asp:BoundField DataField="StoreHours" HeaderText="Hours:" SortExpression="StoreHours" />
<asp:BoundField DataField="StoreEmail" HeaderText="Email:" SortExpression="StoreEmail" />
<asp:BoundField DataField="StoreBrands" HeaderText="Brands Carried:" SortExpression="StoreBrands" />
</Fields>
<RowStyle HorizontalAlign="Left" Font-Size="Medium" />
<EditRowStyle HorizontalAlign="Left" />
</asp:DetailsView>
</div>