Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > v.urgent-need advise-cant sort the datagrid properly

Reply
Thread Tools

v.urgent-need advise-cant sort the datagrid properly

 
 
importantEmail@gmail.com
Guest
Posts: n/a
 
      01-27-2006
hi
i have pasted page_load, my bindgrid, sort and itemdatabound event.
my sorting in not working properly...i tried a couple of ways but there
is something i am missing.
pls suggest me on this .... i hadnt been able to figure out the
solution for this.

here is the original display in the dg==>

Category Description Size(KB) Last Modified
DESKTOP sql engg 397 Jul 28, 2005
DESKTOP relnote 117 Dec 11, 2002
SERVER bullying 92 Aug 23, 2005
SERVER ensuring 73 Aug 23, 2005
SERVER portal users 18 Nov 22, 2005
and after i sort by size here is what i get==>

SERVER ensuring 73 Aug 23, 2005
SERVER bullying 92 Aug 23, 2005
DESKTOP sql engg 397 Jul 28, 2005
SERVER portal users 18 Nov 22, 2005
DESKTOP relnote 117 Dec 11, 2002

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not Me.IsPostBack Then
GetDeptOfUserLogged()
strSQL = "select FILEID, FILENAME,
APPSERVICETYPE,LOCATION,FILEREPORT, DESCRIPTION, location2 FROM
DOWNLOADFILES WHERE (@lower(ORGANISATION)=@lower('" & Session("Orgn") &
"') or @lower(ORGANISATION)='merha') and FILEREPORT='REPORT' order by
APPSERVICETYPE, FILENAME "
bindGrid2()
End If
End Sub

Public Sub bindGrid2()
Try
Page.Validate()
If Not Page.IsValid Then
Return
End If
GoToDBOpenConn()
strSQL = "select FILEID,
FILENAME,APPSERVICETYPE,LOCATION,FILEREPORT, DESCRIPTION, location2
FROM DOWNLOADFILES WHERE (@lower(ORGANISATION)=@lower('" & Orgn & "')
or @lower(ORGANISATION)='merha') and FILEREPORT='REPORT' order by
APPSERVICETYPE, FILENAME "
objCommand = New OleDbCommand(strSQL, objConnection)
myDa.SelectCommand = objCommand
Dim dt As New DataTable
myDa.Fill(dt)
Me.dgFiles.DataSource = dt
Me.dgFiles.DataBind()
Catch ex As Exception
lblError.Text = "bindGrid(): " & ex.Message.ToString
Finally
GoToDBCloseConn()
End Try
End Sub

Sub SortCommand_OnClick(ByVal Source As Object, ByVal E As
System.Web.UI.WebControls.DataGridSortCommandEvent Args)
strSQL = "select FILEID, FILENAME,
APPSERVICETYPE,LOCATION,FILEREPORT, DESCRIPTION, location2 FROM
DOWNLOADFILES WHERE (@lower(ORGANISATION)=@lower('" & Session("Orgn") &
"') or @lower(ORGANISATION)='merha') and FILEREPORT='REPORT'"
GoToDBOpenConn()
myDa.SelectCommand = New
System.Data.OleDb.OleDbCommand(strSQL, objConnection)
myDa.Fill(myDS)
myDS.Tables(0).Columns.Add(New DataColumn("lbl2",
System.Type.GetType("System.DateTime")))
myDS.Tables(0).Columns.Add(New DataColumn("lbl",
System.Type.GetType("System.Int32")))
Dim objView As New DataView(myDS.Tables(0))
objView.Sort = E.SortExpression() & " DESC"
dgFiles.DataSource = objView
dgFiles.DataBind()
End Sub


Private Sub dgFiles_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
dgFiles.ItemDataBound
If e.Item.ItemType =
System.Web.UI.WebControls.ListItemType.Alternating Item Or
e.Item.ItemType = System.Web.UI.WebControls.ListItemType.Item Or
e.Item.ItemType = System.Web.UI.WebControls.ListItemType.EditItem Then
Dim lbl, lbl2 As System.Web.UI.WebControls.Label
Dim row As DataRowView = CType(e.Item.DataItem,
DataRowView)
lbl = e.Item.FindControl("lblSize")
lbl2 = e.Item.FindControl("lblMdDate")
Dim phyPath As String
phyPath =
Server.MapPath(ByteArrayToString(row("LOCATION")))
e.Item.Cells(2).Text = phyPath
FilePath = e.Item.Cells(2).Text
filename = e.Item.Cells(3).Text
Dim fi As FileInfo = New FileInfo(FilePath & filename)
Dim fileBytes As Integer = (fi.Length / 1024)
Dim lastmodifeddt As DateTime =
File.GetLastWriteTime(FilePath & filename)
lbl.Text = fileBytes
lbl2.Text = lastmodifeddt.ToShortDateString
'.ToString("dd MMM yyyy")
Dim urlParams As String = "FileID=" +
row("FILEID").ToString()
Dim tabid As Int32 = 185 'row("TABID1")
e.Item.Cells(4).Text = "<A href='" &
DotNetNuke.Common.Globals.NavigateURL(tabid, "", urlParams) & "'
target=""_parent"">" + ByteArrayToString(row("DESCRIPTION")) & "</A>"
End If
End Sub

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
why doesn't sort properly? filippo2991@virgilio.it Perl Misc 27 02-03-2006 12:50 PM
v.urgent,need experts help, cant sort the datagrid properly samir dsf ASP .Net 0 01-27-2006 01:46 AM
xsl:sort - how do i use it properly? Angus Parvis XML 0 11-16-2004 07:40 PM
Ado sort error-Ado Sort -Relate, Compute By, or Sort operations cannot be done on column(s) whose key length is unknown or exceeds 10 KB. Navin ASP General 1 09-09-2003 07:16 AM
More American Graffiti: Properly Framed, Properly Scored? Scot Gardner DVD Video 0 09-02-2003 02:28 AM



Advertisments