帮忙把下面这段web的程序改成vb.net
各位,如何将下面这个web的程序改成vb.net 的,谢谢!(本人没有接触过web ,用的是vb.net ,所以请大家帮帮忙)
Partial Class _Default
Inherits System.Web.UI.Page
Private m_ldSortExpression As ListDictionary
Private Property SortExpressions() As ListDictionary
Get
m_ldSortExpression = CType(ViewState( "SortExpressions "), ListDictionary)
If m_ldSortExpression Is Nothing Then
m_ldSortExpression = New ListDictionary
End If
Return m_ldSortExpression
End Get
Set(ByVal value As ListDictionary)
ViewState( "SortExpressions ") = value
End Set
End Property
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
BindData()
End If
End Sub
Sub BindData()
' Usually you would get the data from the database.
' To simplify the code, I will just fill a datatable with some standard data.
Dim dt As New DataTable
dt.Columns.Add( "FirstName ")
dt.Columns.Add( "LastName ")
dt.Columns.Add( "Age ")
dt.Columns.Add( "Position ")
dt.Rows.Add(New Object() { "Sonu ", "Kapoor ", 28, "Developer "})
dt.Rows.Add(New Object() { "Mike ", "Mustermann ", 31, "IT-Lead "})
dt.Rows.Add(New Object() { "Jeff ", "Kolb ", 31, "IT-Lead "})
dt.Rows.Add(New Object() { "Josh ", "Lucas ", 37, "Support "})
dt.Rows.Add(New Object() { "Chris ", "Chuck ", 40, "Technical Support "})
Dim dv As DataView = dt.DefaultView
' use a stringbuilder to hold the sortexpression for the dataview
Dim sbSortExpression As New StringBuilder
If SortExpressions.Count > 0 Then
Dim myKeys(SortExpressions.Count) As String
SortExpressions.Keys.CopyTo(myKeys, 0)
For i As Integer = 0 To SortExpressions.Count - 1
sbSortExpression.Append(myKeys(i))
sbSortExpression.Append( " ")
sbSortExpression.Append(SortExpressions(myKeys(i)))
If i <> SortExpressions.Count - 1 Then
sbSortExpression.Append( ", ")
End If
Next
lblSortExpression.Text = sbSortExpression.ToString
' usually we would send that sort-expression now to SQL via some stored-procedure
dv.Sort = sbSortExpression.ToString
Else
lblSortExpression.Text = String.Empty
End If
GridView1.DataSource = dv
GridView1.DataBind()
End Sub
Protected Sub GridView1_Sorting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewSortEventArgs) Handles GridView1.Sorting
m_ldSortExpression = SortExpressions
If Not m_ldSortExpression.Contains(e.SortExpression) Then
m_ldSortExpression.Add(e.SortExpression, e.SortDirection.ToString.Replace( "Ascending ", "ASC ").Replace( "Descending ", "DESC "))
Else
' Get sort direction
Dim strSortDirection As String = m_ldSortExpression.Item(e.SortExpression)
' Was it ascending?
If strSortDirection = "ASC " Then
' Yes, so sort in desc
m_ldSortExpression.Item(e.SortExpression) = "DESC "
ElseIf strSortDirection = "DESC " Then
' it is descending
' remove the sort order
m_ldSortExpression.Remove(e.SortExpression)
End If
End If
SortExpressions = m_ldSortExpression
BindData()
End Sub
End Class
[解决办法]
帮顶上去
[解决办法]
顶顶顶
[解决办法]
这就是vb.net的程序,不知楼主什么意思?
[解决办法]
是不是要把B/S的改成C/S