如何在另一页的详细信息视图中显示从datalist中选择的项目的数据? [英] How can I display data against item selected from datalist on detailsview on another page?
本文介绍了如何在另一页的详细信息视图中显示从datalist中选择的项目的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< asp:DataList ID = DataList1 runat = server DataKeyField = 模型 DataSourceID = SqlDataSource1 RepeatColumns = 5 < span class =code-attribute> RepeatDirection = 水平 Cellpadding = 10 CellSpacing = 10 GridLines = 水平 OnSelectedIndexChanged = DataList1_SelectedIndexChanged >
< ItemTemplate >
< asp:标签 ID = BNameLabel runat = server 文字 =' < ;% #Eval( BName)%> ' / >
< br / >
< asp:Image ID = MImage runat = 服务器 图片 =' <% #Eval( MImage)%> ' 高度 = 150px 宽度 = 100px / >
< br / >
< asp:超链接 ID = ModelLabel href = Details.aspx runat = server 文字 =' <% #Eval( 模型)%> ' / >
< br / >
< br / >
< / ItemTemplate >
< < span class =code-leadattribute> / asp:DataList >
解决方案
在SelectedIndexChanged
内事件,获取所选行并将一些键值作为QueryString
参数传递给下一页。
On下一页,阅读QueryString
值并从DataSource
获取必要的详细信息并绑定的DetailsView
<asp:DataList ID="DataList1" runat="server" DataKeyField="Model" DataSourceID="SqlDataSource1" RepeatColumns="5" RepeatDirection="Horizontal" Cellpadding="10" CellSpacing="10" GridLines="Horizontal" OnSelectedIndexChanged="DataList1_SelectedIndexChanged">
<ItemTemplate>
<asp:Label ID="BNameLabel" runat="server" Text='<%# Eval("BName") %>' />
<br />
<asp:Image ID="MImage" runat="server" Image='<%# Eval("MImage") %>' Height="150px" Width="100px" />
<br />
<asp:Hyperlink ID="ModelLabel" href="Details.aspx" runat="server" Text='<%# Eval("Model") %>' />
<br />
<br />
</ItemTemplate>
</asp:DataList>
解决方案
Inside theSelectedIndexChanged
Event, get the selected row and pass some key value to the next page as aQueryString
Parameter.
On next page, read theQueryString
value and get the necessary details from theDataSource
and bind theDetailsView
.
这篇关于如何在另一页的详细信息视图中显示从datalist中选择的项目的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文