注册 登录
编程论坛 ASP.NET技术论坛

repeater应用的问题

willam 发布于 2008-02-01 16:54, 1450 次点击
在repeater 里面放了一个HyperLink2,,后台代码里面是认不到的,,请问各位高手
类似问题怎么解决

前台代码:
<body>
    <form id="form1" runat="server">
    <div>
        <asp:HyperLink ID="HyperLink1" runat="server" Height="27px" Width="81px">HyperLink</asp:HyperLink>
      
        <asp:Repeater ID="Repeater1" runat="server">
        
        <ItemTemplate>
            <table>
                <tr>
                    
                    <td>
                       <%#Eval("lhttp") %> <%#Eval("lpath") %>
                        <asp:HyperLink ID="HyperLink2" runat="server">HyperLink</asp:HyperLink>
                    </td>
                    
                </tr>
            </table>
        </ItemTemplate>
        </asp:Repeater>
    </div>
    </form>
</body>


后台代码:
using System;
using System.Data;
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 _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
        
        getcon gh = new getcon();//是我自定义一个类
        DataSet o = gh.GetConnString("select * from httplogo order by id","httplogo");类里的方法,返回是一个dataset
        Repeater1.DataSource = o;
        Repeater1.DataBind();
        DataRowView my = o.Tables["httplogo"].DefaultView[0];
        HyperLink1.ImageUrl =Convert.ToString(my.Row["lpath"]);           
        HyperLink1.NavigateUrl = Convert.ToString(my.Row["Lhttp"]);      
        HyperLink2.ImageUrl = Convert.ToString(my.Row["lpath"]);
       HyperLink2.NavigateUrl = Convert.ToString(my.Row["Lhttp"]);
        
    }
}



问题:当前上下文找不到"HyperLink2"

[[it] 本帖最后由 willam 于 2008-2-1 17:50 编辑 [/it]]
6 回复
#2
cyyu_ryh2008-02-01 17:58
要在Item..事件里查找
#3
willam2008-02-01 18:06
[bo]以下是引用 [un]cyyu_ryh[/un] 在 2008-2-1 17:58 的发言:[/bo]

要在Item..事件里查找

不是很明白,可以写一下代码吗???谢谢
#4
willam2008-02-01 21:01
高手不要说一半不说一半吗
#5
cyyu_ryh2008-02-02 15:32
protected void repeaterEmployees_ItemCreated(object sender, RepeaterItemEventArgs e)
        {

            foreach (RepeaterItem item in repeaterEmployees.Controls)
            {
                if (e.Item.ItemType == ListItemType.Item)
                {

                    ddlEmployeeState = (DropDownList)item.FindControl("ddlEmpoyeeState");
                  
            }
        }
#6
willam2008-02-07 13:46
谢谢高手,,前几天还看不明白你的回复,,现在看明白了
#7
cyyu_ryh2008-02-13 11:19
不客气
声明下:
我不是高手
1