参考一个snapnet写的一个Repeater排序,他写的是C#版,我写的是VB.net版

后台代码:
 1   Public   Function DataBindRp(ByVal sort As String)
 2        Try
 3            Dim strsql As String = "select top 20 * from hoo_info"
 4            Dim dt As DataTable = DB.getDataTable(strsql)
 5            Dim dv As DataView = dt.DefaultView
 6            dv.Sort = sort
 7            Me.Repeater1.DataSource = dv
 8            Me.Repeater1.DataBind()
 9        Catch ex As Exception
10            Return False
11        End Try
12    End Function

13
14      Private   Sub Page_Load(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles MyBase.Load
15        If Not IsPostBack Then
16            DataBindRp("di_id ASC")
17        End If
18    End Sub

19
20
21
22      Private   Sub LinkButton1_Click(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles LinkButton1.Click
23        Dim sortString As String = Request.Form("sortstring").ToString()
24        Dim sortfield As String = Request.Form("sortfield").ToString()
25        Dim fullsortstring As String = sortfield + " " + sortString
26        If fullsortstring <> "" And Not fullsortstring Is Nothing Then
27            DataBindRp(fullsortstring)
28        End If
29
30    End Sub
< HTML >
    
< HEAD >
        
< title > asc </ title >
        
< meta  name ="GENERATOR"  content ="Microsoft Visual Studio .NET 7.1" >
        
< meta  name ="CODE_LANGUAGE"  content ="Visual Basic .NET 7.1" >
        
< meta  name ="vs_defaultClientScript"  content ="JavaScript" >
        
< meta  name ="vs_targetSchema"  content ="http://schemas.microsoft.com/intellisense/ie5" >
        
< script  language ="javascript" >
        
function Getsort(obj)
        
{
        document.all.sortfield.value
=obj;
        
if (document.all.sortstring.value == 'ASC')
        
{
            document.all.sortstring.value 
= 'DESC';
        }

        
else if (document.all.sortstring.value == 'DESC')
        
{
            document.all.sortstring.value 
= 'ASC';
        }

        __doPostBack('LinkButton1','');
        }

        
</ script >
    
</ HEAD >
    
< body >
        
< form  id ="Form1"  method ="post"  runat ="server" >
            
< table >
                
< tr >
                    
< td  ondblclick ="Getsort('di_id');" >< b > 双击此处可排序 </ b >< INPUT  type ="hidden"  id ="sortfield"  runat ="server"  NAME ="sortfield" >
                        
< INPUT  type ="hidden"  id ="sortstring"  runat ="server"  value ="ASC"  NAME ="sortstring" ></ td >
                
</ tr >
                
< tr >
                    
< td >
                        
< asp:Repeater  id ="Repeater1"  runat ="server" >
                            
< ItemTemplate >
                                
<% # DataBinder.Eval(container.DataItem,"title" %>
                                
< BR >
                            
</ ItemTemplate >
                        
</ asp:Repeater ></ td >
                
</ tr >
            
</ table >
            
< asp:LinkButton  id ="LinkButton1"  runat ="server" > LinkButton </ asp:LinkButton >
        
</ form >
    
</ body >
</ HTML >

你可能感兴趣的:(VB.NET)