473,407 Members | 2,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

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

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

Jan 27 '06 #1
0 1052

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Stefan Bauer | last post by:
Hi NG, we've got a very urgent problem... :( We are importing data with the LOAD utility. The input DATE field data is in the format DDMMYYYY (for days) and MMYYYY (for months). The target...
28
by: Tamir Khason | last post by:
Follwing the struct: public struct TpSomeMsgRep { public uint SomeId;
16
by: | last post by:
Hi all, I have a website running on beta 2.0 on server 2003 web sp1 and I keep getting the following error:- Error In:...
3
by: N. Spiker | last post by:
I am attempting to receive a single TCP packet with some text ending with carriage return and line feed characters. When the text is send and the packet has the urgent flag set, the text read from...
7
by: Cirene | last post by:
I used to use the Web Deployment Project with my VS2005 projects. Now I've fully upgraded to VS2008. Do I have to download a new version of the Web Deployment Project? If so where can I find...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.