请教panel在repeater中如何应用
将一个表格做成了一个asp:repeater,其中某一单元格里有几个控件,
我用aspanel将其括起来,id为panel1
希望利用其visible属性.
但是在页面中一加载就报错:
编译器错误信息: BC30451: 未声明名称“panel1”。
求高手解决啊 --------------------编程问答-------------------- 写代码时有加System.Web.UI.WebControls.= (System.Web.UI.WebControls.DataList)e.Item.FindContro()吗? --------------------编程问答-------------------- 不好意思,我是初学的.请问这一句应该放哪里啊.
放上我的源代码.
<%@ Page Language="VB" ContentType="text/html"%>
<%@ Register TagPrefix="ztNamespace" TagName="ztRights" src="ztRights.ascx"%>
<%@ Register TagPrefix="MM" Namespace="DreamweaverCtrls" Assembly="DreamweaverCtrls,version=1.0.0.0,publicKeyToken=836f606ede05d46a,culture=neutral" %>
<MM:DataSet
id="DataSet1"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_conn") %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABASETYPE_conn") %>'
CommandText='<%# "SELECT * FROM MessageBook ORDER BY id DESC" %>'
Debug="true" PageSize="5" CurrentPage='<%# IIf((Request.QueryString("DataSet1_CurrentPage") <> Nothing), Request.QueryString("DataSet1_CurrentPage"), 0) %>'
></MM:DataSet>
<MM:PageBind runat="server" PostBackBind="true" />
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<link href="1.css" rel="stylesheet" type="text/css">
</head>
<body><center>
<form runat="server">
<table width="70%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><a href="Write.aspx"><img src="images/new.gif" width="72" height="21" border="0"></a></td>
<td align="right"><a href="login.aspx">管理员登陆</a></td>
</tr>
</table>
<table width="70%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20%"></td>
<td> </td>
</tr>
</table>
<hr size="3" width="75%">
<br>
<table border="0" width=50%>
<tr>
<td width="25%"><MM:If runat="server" Expression='<%# (DataSet1.CurrentPage <> 0) %>'>
<ContentsTemplate> <a href="<%# Request.ServerVariables("SCRIPT_NAME") %>?DataSet1_currentPage=0"><img src="First.gif" border=0></a> </ContentsTemplate>
</MM:If>
</td>
<td width="25%"><MM:If runat="server" Expression='<%# (DataSet1.CurrentPage <> 0) %>'>
<ContentsTemplate> <a href="<%# Request.ServerVariables("SCRIPT_NAME") %>?DataSet1_currentPage=<%# Math.Max(DataSet1.CurrentPage - 1, 0) %>"><img src="Previous.gif" border=0></a> </ContentsTemplate>
</MM:If>
</td>
<td width="25%"><MM:If runat="server" Expression='<%# (DataSet1.CurrentPage < DataSet1.LastPage) %>'>
<ContentsTemplate> <a href="<%# Request.ServerVariables("SCRIPT_NAME") %>?DataSet1_currentPage=<%# Math.Min(DataSet1.CurrentPage + 1, DataSet1.LastPage) %>"><img src="Next.gif" border=0></a> </ContentsTemplate>
</MM:If>
</td>
<td><MM:If runat="server" Expression='<%# (DataSet1.CurrentPage < DataSet1.LastPage) %>'>
<ContentsTemplate> <a href="<%# Request.ServerVariables("SCRIPT_NAME") %>?DataSet1_currentPage=<%# DataSet1.LastPage %>"><img src="Last.gif" border=0></a> </ContentsTemplate>
</MM:If>
</td>
</tr>
</table>
记录 <%= IIf((DataSet1.RecordCount = 0), 0, (DataSet1.StartRecord + 1)) %> 到 <%= DataSet1.EndRecord %> 总共 (<%= DataSet1.RecordCount %>)条留言<table width="75%" border="0">
<tr>
<td width="50%" align="center">总共有<%# DataSet1.LastPage+1%>页 第<%= DataSet1.CurrentPage + 1 %>页</td>
<td align="center">
<%
Dim i as integer
for i=1 to (DataSet1.LastPage+1)
if (DataSet1.CurrentPage +1)=i Then
Response.Write("<font color=#ff0000><strong>" & i & "</strong></font> ")
Else
Response.Write("<a href=""Index.aspx?DataSet1_CurrentPage=" & (i-1) & """>" & i & "</a> ")
End If
Next
%>
</td>
</tr>
</table>
<ASP:Repeater runat="server" DataSource='<%# DataSet1.DefaultView %>'>
<ItemTemplate>
<table width="70%" border="0" cellspacing="0" cellpadding="0" class="unnamed1">
<tr>
<td valign="middle">QQ<img src="images/QQ.gif" alt='<%# DataSet1.FieldValue("qq", Container) %>'> 主页<a href="<%# DataSet1.FieldValue("homepage", Container) %>"><img src="images/home.gif" alt='<%# DataSet1.FieldValue("homepage", Container) %>' width="23" height="22" border="0"></a> 邮箱<a href="mailto:<%# DataSet1.FieldValue("Email", Container) %>"><img src="images/email.gif" alt='<%# DataSet1.FieldValue("Email", Container) %>' width="23" height="22" border="0"></a></td>
<td align="right" valign="middle"><asp:Panel runat="server" ID="Panel1"><asp:Panel runat="server" ID="t1" Visible="false"><a href="edit.aspx?id=<%# DataSet1.FieldValue("id",Container)%>"><img src="images/edit.gif" width="72" height="21" border="0"></a> <a href="del.aspx?id=<%# DataSet1.FieldValue("id",Container)%>"><img src="images/del.gif" name="delete" width="72" height="21" border="0" id="delete"></a><a href="del.aspx?id=<%# DataSet1.FieldValue("id",Container)%>"></a> <a href="reply.aspx?id=<%# DataSet1.FieldValue("id",Container)%>"><img src="images/hf.gif" width="72" height="21" border="0"></a></asp:Panel></td>
</tr>
</table>
<br>
<table width="70%" border="1" cellspacing="0" cellpadding="0" class="unnamed1" style="border-collapse:collapse;table-layout: fixed;WORD-BREAK: break-all; WORD-WRAP: break-word" >
<tr>
<td width="20%"><%# DataSet1.FieldValue("MessageName", Container) %></td>
<td>主题:<%# DataSet1.FieldValue("title", Container) %></td>
</tr>
<tr>
<td width="20%"><img src='<%# DataSet1.FieldValue("face", Container) %>'></td>
<td><%# DataSet1.FieldValue("MessageBook", Container) %></td>
</tr>
<tr>
<td width="20%"> </td>
<td><img src="images/ip.gif" width="13" height="15">IP<%# DataSet1.FieldValue("UserIP", Container) %> 留言时间<%# DataSet1.FieldValue("TimeInsert", Container) %></td>
</tr>
<tr>
<td> </td>
<td><%# DataSet1.FieldValue("Miange", Container) %></td>
</tr>
</table>
<hr size="1" width="75%">
</ItemTemplate>
</ASP:Repeater>
<br>
<asp:Button runat="server" OnClick="buttonclick" Text="submit"/>
</form>
<ztNamespace:ztRights runat="Server"/>
</center>
</body>
</html>
<script runat="server">
Sub buttonClick(s As Object,e As EventArgs)
p1.visible="true"
End Sub
</script> --------------------编程问答-------------------- 我想用asp:panel将编辑/回复/删掉这三个控件框起来.隐藏
读到session后再显示.
但是出错,
没办法,加了一个button强制执行测试,还是不行.
一加载就出错,错误信息如一楼.
虚心请教原因 --------------------编程问答-------------------- 不光是不能在repeater中应用panel,将功能控件改用asp:imagebutton也不行, --------------------编程问答-------------------- 顶上去,在线等. --------------------编程问答-------------------- 有一点点想法了,
panel必须做数据绑定
<asp:Panel runat="server" ID="Panel<%# DataSet1.FieldValue("id",Container)%>"></asp:panel>
但是不知道程序怎么写 --------------------编程问答-------------------- 上述想法不对 --------------------编程问答-------------------- 还没有搞懂 --------------------编程问答-------------------- 不知道你要做什么。为什么要加个panel --------------------编程问答-------------------- 回楼上,我想用panel
将回复/编辑/删除这几个功能控件
用session判断一起隐藏显示 --------------------编程问答-------------------- 郁闷,关注一天了 --------------------编程问答-------------------- 自已顶起,原理似乎已经找到了,控制repeater中某个控件的属性
<asp:Repeater runat="server" id="rptLinkButton" onItemCommand="Button_Click">
<itemtemplate>
<li>
<asp:LinkButton runat="server" Text='<%# Container.DataItem("au_fname")%>' Visible="true"/>
</li>
</itemtemplate></asp:Repeater>
==========================
--------------------编程问答-------------------- 刚好最近看到一个类似的例子 拿去试试行不行
Sub rptLinkButton_Click(s As Object,e As RepeaterCommandEventArgs)
Dim lbtnSelected As LinkButton
lbtnSelected=e.Item.Controls(1)
lbtnSelected.visible=false
lblmsg.Text="you Selected " & lbtnSelected.Text
End Sub
<asp:Panel ID="manages" runat="server" Visible='<%# Session["nName"]!=null %>'>
<hr size="1" style="border:1px dotted #333;">
<a href="Reply.aspx?id=<%# Eval("id") %>">[回复]</a>
<a href="Default.aspx?action=del&id=<%# Eval("id") %>" onclick='return confirm("您确定删除吗?");'>[删除]</a>
<a href="Default.aspx?action=loginout" onclick='return confirm("您确定要退出管理模式吗?");'>[注销]</a>
<a href="RePass.aspx?id=<%# Eval("id") %>">[修改密码]</a>
</asp:Panel> --------------------编程问答-------------------- 我也刚开始也好奇, 提示找不到控件. 然后发现自动生成的代码被删除了..
最后思考了下.. asp:repeater 内不让放容器控件吧.
不相信你试试, 把Panel 拿到外面立刻就好了. --------------------编程问答-------------------- 楼上也是我, 登错帐号了.
(Repeater1.Items[0].FindControl("Panel1") as Panel1).
刚搜到,你试试. --------------------编程问答-------------------- --------------------编程问答-------------------- Panel p = top.FindControl("p") as Panel; --------------------编程问答-------------------- <asp:Repeater runat="server" ID="top">
<ul>
<asp:Panel runat="server" ID= "p">
</asp:Panel>
</ul>
</asp:Repeater>
------------
Panel p = top.FindControl("p") as Panel;
--------------------编程问答-------------------- 不知道楼主为何要这样做,repeater里面有个事件控制repeater的显示的,在判断Session的时候可以重新加载一下那个事件即可判断,无需使用repeater
补充:.NET技术 , ASP.NET