این هم برای آیندگان ...
کد کامل توی VB میشه
Private Sub ArticlesGrid_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles ArticlesGrid.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim IsThisEnable As Integer = Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "art_publish"))
Dim txt As Label = DirectCast(e.Row.FindControl("lblStatus"), Label)
If IsThisEnable = 1 Then
txt.Text = "فعال"
Else
txt.Text = "غیر فعال"
End If
End If
End Sub
بعد موضوعی که می مونه اینه که بعد از این کار دیگه Sorting و Paging کار نمی کنه و خطا میده . که راه حلش این کد ها هست .
Private Sub ArticlesGrid_PageIndexChanging1(sender As Object, e As GridViewPageEventArgs) Handles ArticlesGrid.PageIndexChanging
ArticlesGrid.PageIndex = e.NewPageIndex
ArticlesGrid.DataBind()
End Sub
Private Function ConvertSortDirectionToSql(sortDirection__1 As SortDirection) As String
Dim newSortDirection As String = [String].Empty
Select Case sortDirection__1
Case SortDirection.Ascending
newSortDirection = "ASC"
Exit Select
Case SortDirection.Descending
newSortDirection = "DESC"
Exit Select
End Select
Return newSortDirection
End Function
Private Sub ArticlesGrid_Sorting(sender As Object, e As GridViewSortEventArgs) Handles ArticlesGrid.Sorting
Dim dataTable As DataTable = TryCast(ArticlesGrid.DataSource, DataTable)
If dataTable IsNot Nothing Then
Dim dataView As New DataView(dataTable)
dataView.Sort = e.SortExpression + " " + ConvertSortDirectionToSql(e.SortDirection)
ArticlesGrid.DataSource = dataView
ArticlesGrid.DataBind()
End If
End Sub
یعنی عملیات رو باید به صورت دستی انجام بدیم .
موفق باشید ./