本来是研究模版接口的,但是后来发现用用户控件也能实现类似datalist的控件,自己感觉还算方便,不过不知道有没有实际作用。

更新按钮没有添加事件,但是如果要添加的话也是很简单地~

查看:    http://my.ht91.com/aaronlly/test/test.aspx


test.aspx

Public Sub page_load()
      
        
Dim strConn, strSQL As String
        
Dim myConn As OleDbConnection
        
Dim myCommand As OleDbCommand
        
Dim dr As OleDbDataReader

        strSQL 
= "select * from member order by id"

        strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("."& "/db1.mdb"

        myConn = New OleDbConnection(strConn)

        myCommand 
= New OleDbCommand(strSQL, myConn)

        myConn.Open()

        dr 
= myCommand.ExecuteReader()
                        
        
While dr.Read
                
            
Dim tt As New testuc_ascx
            PlaceHolder1.Controls.Add(tt)
            tt.idnum 
= dr("id")
            tt.username 
= dr("user")
                
        
End While
                
        myConn.Close()

    
End Sub

testuc.ascx 

    Public Property idnum() As String
        
        
Get
            
            
Return idnumtext.Text
            
        
End Get
        
        
Set(ByVal value As String)
            
            idnumtext.Text 
= value
            
        
End Set
        
    
End Property

    
    
Public Property username() As String
        
        
Get
            
            
Return usernametext.Text
            
        
End Get
        
        
Set(ByVal value As String)
            
            usernametext.Text 
= value
            
        
End Set
        
    
End Property

       
    
    
Sub edit_click(ByVal sender As ObjectByVal e As EventArgs)
        
        panel1.Visible 
= True
        usernametext.Visible 
= False
        edit.Visible 
= False
        
    
End Sub

    
    
    
Sub cancel_click(ByVal sender As ObjectByVal e As EventArgs)
        
        panel1.Visible 
= False
        usernametext.Visible 
= True
        edit.Visible 
= True
        nametext.Text 
= ""
        
    
End Sub

 

id:<asp:Label runat="server" ID="idnumtext"></asp:Label><br />
name:
<asp:Label runat="server" ID="usernametext"></asp:Label>
<asp:Panel runat="server" ID="panel1" Visible =false >
    
<asp:TextBox runat="server" ID="nametext"></asp:TextBox>
    
<asp:Button runat="server" ID="save" Text="save"></asp:Button>
    
<asp:Button runat="server" ID="cancel" Text="cancel" OnClick =cancel_click></asp:Button>
</asp:Panel>
<br />
<asp:LinkButton runat="server" ID="edit" OnClick="edit_click">Edit</asp:LinkButton>
<hr size="1" color="silver" width="100%" align="left" />

 

 

posted on 2005-09-02 10:00  aaron.net  阅读(455)  评论(1编辑  收藏  举报