转发器控制与图像框和一些标签 [英] repeater control with image box and a few labels

查看:95
本文介绍了转发器控制与图像框和一些标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

请帮我创建一个带有图像框的转发器控件和一些用于在另一侧写文本的标签。

我想要转发器看起来像

http://www.lovevivah.com/ index.php / search_controller / process_quick_search / [ ^ ]。

谢谢

Hi all,
Please help me in creating a repeater control with image box on one side and a few labels for writing texts on the other.
I want the repeater to look like the one in
http://www.lovevivah.com/index.php/search_controller/process_quick_search/[^].
Thank You

推荐答案

hi skand pratal singh,



请参阅下面的代码。它将解决您的问题。我已经实现了它:



.aspx代码:



hi skand pratal singh,

Please see below code.it will solve your problem. i have implemented it:

.aspx code:

<asp:Repeater ID="rpt" runat="server" OnItemDataBound="rpt_ItemDataBound">
                <ItemTemplate>
                    <table>
                        <tr>
                            <td>
                                <asp:Image ID="img" runat="server" ImageUrl='<%#"~/images/"+Eval("Image") %>' Width="160px" Height="169px"/>
                            </td>
                            <td>
                                <table>
                                    <tr>
                                        <td>
                                            Name :
                                        </td>
                                        <td>
                                            <asp:Label ID="lblname" runat="server" Text='<%#Eval("Firstname") %>'></asp:Label></td>
                                    </tr>
                                    <tr>
                                        <td>
                                            Mobile :
                                        </td>
                                        <td>
                                            <asp:Label ID="lblmobile" runat="server" Text='<%#Eval("Mobile") %>'></asp:Label></td>
                                    </tr>
                                    <tr>
                                        <td>
                                            Salary :
                                        </td>
                                        <td>
                                            <asp:Label ID="lblsalary" runat="server" Text='<%#Eval("Salary") %>'></asp:Label></td>
                                    </tr>
                                    <tr>
                                        <td>
                                            Sex :
                                        </td>
                                        <td>
                                            <asp:Label ID="lblsex" runat="server" Text='<%#Eval("Sex") %>'></asp:Label></td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                </ItemTemplate>
            </asp:Repeater>





.aspx.cs代码:





.aspx.cs code:

using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Default3 : System.Web.UI.Page
{
    SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["Demo"]);
    protected void Page_Load(object sender, EventArgs e)
    {
        bindRepeater();
    }

    private void bindRepeater()
    {
        con.Open();
        SqlCommand cmd = new SqlCommand("select * from contact", con);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataTable dt = new DataTable();
        da.Fill(dt);
        if (dt.Rows.Count > 0)
        {
            rpt.DataSource = dt;
            rpt.DataBind();
        }
        con.Close();
    }
   
}


这篇关于转发器控制与图像框和一些标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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