如何在Repeater控件的一行中显示不同的字段? [英] How to display different fields in a row of the Repeater Control?

查看:63
本文介绍了如何在Repeater控件的一行中显示不同的字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个中继器控件.其中有一个图像按钮,用于显示与电影"表的每一行相对应的图像.

现在我想在单击特定图像后,在页面的文本框中显示其他字段(例如电影名称,星空等).与电影图像对应的字段.

怎么做?请帮忙.
检查下面的代码:

I have a repeater control. In it, I have an image button which shows the images corresponding to each row of my Movie table.

Now I want to display some other fields(like moviename,starcast etc.) in the text boxes in the page,after clicking a particular image,i.e. fields corresponding to the movie image clicked.

How to do that? Please help.
Check my code below:

<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1"

            >
        <ItemTemplate>
            <table id="Table1" cellpadding="1" cellspacing="1" visible ="true">
            <tr>
                <td width="50px">
                <td width="20px">
                    <p align="left">
                    <%--<asp:Label ID="MovieID" runat = "server" Text='<%# DataBinder.Eval(Container.DataItem,"Mov_ID")%>' >
                    </asp:Label>--%>

                    </p>
                </td>
                <td width="100px">
                <p align="left">

                    <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl='<%#Eval("ImagePath") %>'

                     style="height:100px;width:100px;border:1px solid gray;"/>
               </td>
                </p>
                </td>
                </table>
        </ItemTemplate>

        </asp:Repeater>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server"

            ConnectionString="<%$ ConnectionStrings:testConnectionString %>"

            SelectCommand="SELECT [Mov_ID], [Mov_name], [StarCast], [Mov_Priority],[ImagePath] FROM [Movie]">
        </asp:SqlDataSource>
//below I want to display the related infos in the text boxes.
<asp:TextBox ID="txtMovName" runat="server"></asp:TextBox>
 <asp:TextBox ID="txtStarCast" runat="server"></asp:TextBox>

推荐答案

ConnectionStrings:testConnectionString span> =" 从[电影]中选择[Mov_ID],[Mov_name],[StarCast],[Mov_Priority],[ImagePath]" < /asp:SqlDataSource > //下面我想在文本框中显示相关信息. < asp:TextBox ID =" runat 服务器" < > < asp:TextBox ID =" runat 服务器" < >
ConnectionStrings:testConnectionString %>" SelectCommand="SELECT [Mov_ID], [Mov_name], [StarCast], [Mov_Priority],[ImagePath] FROM [Movie]"> </asp:SqlDataSource> //below I want to display the related infos in the text boxes. <asp:TextBox ID="txtMovName" runat="server"></asp:TextBox> <asp:TextBox ID="txtStarCast" runat="server"></asp:TextBox>


你好,
您可以通过以下方法做到
1-图像按钮支持项目命令,指定命令名称和命令参数并实现itemcommand事件,并通过影片ID选择数据,然后显示所需的影片信息,
这种方法会降低性能.
2-用javascript做的更好,
您应该使用datareader而不是数据集,因为转发器是断开连接的数据
Hello,
u can do it by to approaches
1- image button support item command , specify the command name and command argument and implement the itemcommand event and select the data by the movie id and then display the movie info u want,
the approach is bad performance.
2- do it by javascript is better,
u should use datareader not dataset because repeater is disconnected data


这篇关于如何在Repeater控件的一行中显示不同的字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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