如何在另一页的详细信息视图中显示从datalist中选择的项目的数据? [英] How can I display data against item selected from datalist on detailsview on another page?

查看:87
本文介绍了如何在另一页的详细信息视图中显示从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 the SelectedIndexChanged Event, get the selected row and pass some key value to the next page as a QueryString Parameter.

On next page, read the QueryString value and get the necessary details from the DataSource and bind the DetailsView.


这篇关于如何在另一页的详细信息视图中显示从datalist中选择的项目的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆