Advertisement

03.27.2007 at 08:51AM PDT, ID: 22475208
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.2

sorting on a datagrid

Asked by SirReadAlot in Microsoft Visual Basic.Net

Hi experts,
I am trying to sort on a datagrid.

i have performed these steps, but how come i can't still sort on the grid.
==================================================================================
   Public Property sortCriteria() As String
        Get
            Return CStr(viewstate("sortCriteria"))
        End Get
        Set(ByVal Value As String)
            ViewState("sortCriteria") = Value
        End Set
    End Property
===========================================================================
    ' Holds the direction to be sorted...
    Public Property sortDir() As String
        Get
            Return CStr(viewstate("sortDir"))
        End Get
        Set(ByVal Value As String)
            ViewState("sortDir") = Value
        End Set
    End Property
============================================================================================
    Sub dgusers_Sort(ByVal sender As Object, ByVal e As DataGridSortCommandEventArgs) Handles dgUsers.SortCommand
        ' Check to see if the column we clicked on is the current column defined
        ' in the sortCriteria property.
        If Me.sortCriteria = e.SortExpression Then
            If Me.sortDir = "desc" Then
                Me.sortDir = "asc"
            Else
                Me.sortDir = "desc"
            End If
        End If
        ' Assign the column clicked to the sortCriteria property
        Me.sortCriteria = e.SortExpression
        ' Now call the procedure to re-display the Data Grid
    End Sub
============================================================================================
#Region "LoadData Subroutine "
    Private Sub LoadData()
        'Calls the GetAllUser Function
        dgUsers.DataSource = LicenseDB.GetAllUser(Me.sortDir, Me.sortCriteria)
        dgUsers.DataBind()
    End Sub
#End Region
==========================================================
then this is the getalluser function


    'fills the datagrid with details
    Public Shared Function GetAllUser(ByVal sortDir As String, ByVal sortCriteria As String) As ArrayList
        Dim arr As New ArrayList
        Dim DBConnection As SqlConnection = Connection()
        DBConnection.Open()
        Dim cmdLicense As SqlCommand = New SqlCommand("SPR_GETALL_USERPROFILE", DBConnection)
        cmdLicense.CommandType = CommandType.StoredProcedure
        Try
            Dim drlicense As SqlDataReader
            drlicense = cmdLicense.ExecuteReader()
            While drlicense.Read()
                Dim userProfile As New UserProfile
                userProfile.userProfileID = DataUtil.IsNull(drlicense.Item("userProfileID"), "")
                userProfile.firstName = DataUtil.IsNull(drlicense.Item("firstName"), "")
                userProfile.lastName = DataUtil.IsNull(drlicense.Item("lastName"), "")
                userProfile.address1 = DataUtil.IsNull(drlicense.Item("address1"), "")
                userProfile.address2 = DataUtil.IsNull(drlicense.Item("address2"), "")
                userProfile.city = DataUtil.IsNull(drlicense.Item("city"), "")
                userProfile.state = DataUtil.IsNull(drlicense.Item("state"), "")
                userProfile.zip = DataUtil.IsNull(drlicense.Item("zip"), "")
                userProfile.email = DataUtil.IsNull(drlicense.Item("email"), "")
                userProfile.phone = DataUtil.IsNull(drlicense.Item("phone"), "")
                ' userProfile.employeeflag = DataUtil.IsNull(drlicense.Item("employeeflag"), "")
                userProfile.employeeflag = DataUtil.IsNull(drlicense.Item("employee_Non_employee"), "")
                ' userProfile.employeeflag = DataUtil.IsNull(drlicense.Item("employeeflag"), 0)
                userProfile.username = DataUtil.IsNull(drlicense.Item("username"), "")
                userProfile.password = DataUtil.IsNull(drlicense.Item("password"), "")
                arr.Add(userProfile)
            End While
            Return arr
        Finally
            DBConnection.Close()
        End Try
    End Function
============================================================
CREATE PROCEDURE dbo.SPR_GETALL_USERPROFILE
@SortColumn varchar(255),
@Direction varchar(10)
AS

declare @SQL varchar(8000)
 BEGIN
SELECT  @SQL = 'SELECT          
           userLogin.username,
           userLogin.password,
           userProfile.userProfileID,
           userProfile.firstName,
           userProfile.lastName,
           userProfile.address1,
           userProfile.address2,
           userProfile.city,
           userProfile.state,
           userProfile.zip,
           userProfile.email,
           userProfile.phone,
           userProfile.employeeflag,
         case employeeflag when 1 then "employee" else "Non employee" end as employee_Non_employee
FROM       userLogin INNER JOIN
           userProfile ON userLogin.userProfileID = userProfile.userProfileID
            ORDER BY ' + str(@SortColumn) + '  ' + @Direction
exec(@SQL)  
end
GO


how do i get my sort functionality

thanks


Start Free Trial
[+][-]03.27.2007 at 10:07AM PDT, ID: 18801496

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Microsoft Visual Basic.Net
Sign Up Now!
Solution Provided By: piyush_soni
Participating Experts: 1
Solution Grade: A
 
 
[+][-]03.27.2007 at 10:49AM PDT, ID: 18801872

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.28.2007 at 02:35AM PDT, ID: 18806685

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.29.2007 at 06:02AM PDT, ID: 18815581

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32