惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
爱范儿
爱范儿
J
Java Code Geeks
L
LangChain Blog
V
V2EX
大猫的无限游戏
大猫的无限游戏
S
SegmentFault 最新的问题
博客园 - Franky
Microsoft Azure Blog
Microsoft Azure Blog
Jina AI
Jina AI
Blog — PlanetScale
Blog — PlanetScale
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The Cloudflare Blog
博客园 - 司徒正美
B
Blog
G
Google Developers Blog
Stack Overflow Blog
Stack Overflow Blog
罗磊的独立博客
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Apple Machine Learning Research
Apple Machine Learning Research
Engineering at Meta
Engineering at Meta
MyScale Blog
MyScale Blog
有赞技术团队
有赞技术团队
Hugging Face - Blog
Hugging Face - Blog

博客园 - 生活即技术

好久不更新了,忙的惭愧哦,思考一个应用 利用dataTable 排序的解决方法 项目中遇到的一些小问题及解决方法 常用代码 一个com+消息队列的例子 部署Com+ 2004我的爱,2005我的期待 加密解密相关 生成略缩图 论坛在线人数统计代码 上礼拜六犯的愚蠢错误 正则表达式(1) 又一新的分页方法(转帖) 用户控件的使用(一) DataList的使用(二)自定义分页的实现 DataList的使用(1) DataGrid的使用(2)自定义分页 DataGrid的使用(1)
用户控件的使用(二)
生活即技术 · 2004-11-17 · via 博客园 - 生活即技术

这个是用引用动态的添加用户控件
UserControl.aspx

<%@ Reference Control="MyControl_.ascx" %>
<%@ register tagprefix="My" tagname="user" src="MyControl_.ascx" %>
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="UserControls.aspx.vb" Inherits="Data.UserControls"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
    
<HEAD>
        
<title>UserControls</title>
        
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
        
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
        
<meta content="JavaScript" name="vs_defaultClientScript">
        
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
    
</HEAD>
    
<body MS_POSITIONING="GridLayout">
        
<form runat="server">
            
<asp:Table Runat="server" id="Table1" style="Z-INDEX: 101; LEFT: 152px; POSITION: absolute; TOP: 80px"
                Width="104px">
                
<asp:TableRow>
                    
<asp:TableCell  ID="Cell"><asp:PlaceHolder id="PlaceHolder1" runat="server"></asp:PlaceHolder></asp:TableCell>
                
</asp:TableRow>
            
</asp:Table>
            
        
</form>
    
</body>
</HTML>

UserControl.aspx.vb

 Private Sub Page_Load(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles MyBase.Load
        
Dim myControl As MyControl = CType(Page.LoadControl("MyControl_.ascx"), MyControl)
        myControl.MyProperty1 
= "Color"
        'Page.Controls.Add(myControl)
        Me.PlaceHolder1.Controls.Add(myControl)
        
'Table1.Controls.Add(myControl)
    End Sub

用户控件页 MyControl_.ascx

<%@ Control classname="MyControl1" Language="vb" AutoEventWireup="false" Codebehind="MyControl_.ascx.vb" Inherits="Data.MyControl" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<FONT face="宋体">
    
<asp:DataList id="DataList1" runat="server">
    
<ItemTemplate>
    
<%# container.dataitem("id")%>
    
    
</ItemTemplate>
        
</asp:DataList></FONT>

用户控件页 MyControl_.ascx.vb


    
Private Sub Page_Load(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles MyBase.Load
        
If Not IsPostBack Then
            DataList1.DataSource 
= Databind_(0).Tables("user_login")
            DataList1.DataBind()
        
End If
    
End Sub

    
Function Databind_(ByVal StartIndex) As System.Data.DataSet
        
Dim Sqlstr As String = "server=(local);database=Achem56;uid=sa;pwd= "
        Dim Sql As String = "select   id,uname from user_login  "
        Dim Sqlconn As New System.Data.SqlClient.SqlConnection(Sqlstr)
        
Dim Sqlcmd As New System.Data.SqlClient.SqlDataAdapter(Sql, Sqlconn)
        
Dim SqlDataSet As New DataSet
        Sqlcmd.Fill(SqlDataSet, StartIndex, 
10"user_login")
        
Return SqlDataSet
    
End Function

Databin_()中的Sqlcmd.Fill()用的是返回特定大小行的记录,是从昨天写的考过来的,今天懒的写了。呵呵