Gridview'de Sıralama ile ilgili bir sorunum var. Ben bu konuda uzman değilim. vb.net ama bu sorunu çözmek zorundayım. Verilerimin Gridview'e nasıl geldiğini açıklamak istiyorum.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
//also there is some logic in there but I think that part of the code will not effect
loadgrid()
End Sub
loadgrid()
bazı adımlardan geçerek sorgu verileri için yüklenecek
//Bu işlev bazı mantık için kullanılır
Private Sub loadgrid() Handles B_SEARCH.Click, chkLegacy.CheckedChanged, gvEmployer.PageIndexChanged
GridDataLoader()
End Sub
eEmployer
gridView için sorgu için tüm verileri alacak
Public Sub GridDataLoader()
//some code was there because of searching
Dim dataTable = Employer.getEmployers(eEmployer, chkLegacy.Checked)
gvEmployer.DataBind()
End Sub
Public Function GetEmployers(ByVal eEmployer As tblEmployer, ByVal All As Boolean, Optional ByVal sortExpression As String = Nothing) As DataTable
Dim query = ""
query =
"select employer.EmployerID as EmployerId,
employer.Employer_Name as EmployerName,
// the query is so large so i delete all for better understanding
on (employer.Modified_by=tum.UserID)
where employer.LegacyID IS NULL and address.ValidityTo is null"
'End If
Dim params = ""
If All = False Then
query += " AND employer.ValidityTo is null"
End If
If (params.Trim() IsNot "") Then
query = query & params
End If
data.setSQLCommand(query, CommandType.Text)
Return data.Filldata
End Function
son olarak, veriler kılavuz görünümüne geri dönüyor. ama benim sorunum, sıralama olayını nasıl uygulayabileceğimi anlamıyorum. değiştirdim bir şey görünümdür AllowSorting="true"
SortExpression="EmployerName"
daha ne yapmam gerektiğini de bilmiyorum. Ben aşağıdaki Bu Madde