问题是:在<asp:repeater></asp:repeater>内有一个<asp:Panel runat="server" id="pane1" >控件,我要想在sub page_load程序中设pane1.visible=false请问怎样写法:直接写不能找到pane1控件,如果用 Repeater1.FindControl("pane11").Visible = False,显示错误是:无法为控件赋值.请问正确的应怎样写?我的代码是:
<script runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim strsql As String
Dim dtrdrop As OleDbDataReader
strsql = "select top " & num & " * from news"
Repeater1.FindControl("pane11").Visible = False
cmdselect = New OleDbCommand(strsql, conpubs)
conpubs.Open()
dtrdrop = cmdselect.ExecuteReader
Repeater1.DataSource = dtrdrop
Repeater1.DataBind()
conpubs.Close()
End Sub
</script>
<asp:repeater id="Repeater1" runat="server" EnableViewState="False">
<ItemTemplate>
document.write('<tr><td height="20" class="p9gl2"><li><%#Left(DataBinder.Eval(Container.DataItem, "title"), titlelen)%><asp:Panel runat="server" id="panel1" visible=false><font size=-1>[<asp:Label id="tm" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "tm")%>'></asp:Label>]</asp:Panel></font></td></tr>');
</ItemTemplate>
</asp:repeater>
<script runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim strsql As String
Dim dtrdrop As OleDbDataReader
strsql = "select top " & num & " * from news"
Repeater1.FindControl("pane11").Visible = False
cmdselect = New OleDbCommand(strsql, conpubs)
conpubs.Open()
dtrdrop = cmdselect.ExecuteReader
Repeater1.DataSource = dtrdrop
Repeater1.DataBind()
conpubs.Close()
End Sub
</script>
<asp:repeater id="Repeater1" runat="server" EnableViewState="False">
<ItemTemplate>
document.write('<tr><td height="20" class="p9gl2"><li><%#Left(DataBinder.Eval(Container.DataItem, "title"), titlelen)%><asp:Panel runat="server" id="panel1" visible=false><font size=-1>[<asp:Label id="tm" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "tm")%>'></asp:Label>]</asp:Panel></font></td></tr>');
</ItemTemplate>
</asp:repeater>
关注!!!
private void Page_Load(object sender, System.EventArgs e)
{
if( !Page.IsPostBack )
{
BindBookList();
}
} private void BindBookList()
{
if( ds != null )
ds.Dispose();
ds = BookSvc.DisplayBooksList();
BooksList.DataSource = ds.Tables[0];
BooksList.DataBind();
for( int i = 0; i<ds.Tables[0].Rows.Count; i++ )
{
if( this.Request.UserHostAddress.ToString() != ds.Tables[0].Rows[i]["ipaddress"].ToString() )
{
BooksList.Items[i].FindControl("btnDel").Visible = false;
}
}
}
foreach(Control ctl in this.repeater1.Items)
{
foreach(Control c in ctl.Controls)
{
if(c is System.Web.UI.WebControls.Panel)
c.Visible = false;
}
}