urg-how to sort datagrid having calculated column

Discussion in 'ASP .Net' started by samir, Dec 21, 2005.

  1. samir

    samir Guest

    hi
    i have a datagrid where i display some columns. i want to have some
    columns from the db and 2 i calculate,i can display it but problem is
    how to sort the calculated columns.
    here is what i am doing right now:

    on page load i have:
    If Not Me.IsPostBack Then
    strSQL = "select FILEID, FILENAME,
    APPSERVICETYPE,LOCATION,FILEREPORT, DESCRIPTION, location2 FROM
    DOWNLOADFILES WHERE (@lower(ORGANISATION)=@lower('" & Orgn & "') or
    @lower(ORGANISATION)='dfe') and FILEREPORT='REPORT' order by
    APPSERVICETYPE, FILENAME "
    bindGrid()
    End If


    and in bindgrid i have :
    GoToDBOpenConn()
    bjCommand = New OleDbCommand(strSQL, objConnection)
    myDa.SelectCommand = objCommand
    Dim dt As New DataTable
    myDa.Fill(dt)
    Me.dgFiles.DataSource = dt
    Me.dgFiles.DataBind()

    in itemdatabound i calculate the columns
    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.AlternatingItem 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 Date =
    File.GetLastWriteTime(FilePath & filename)
    lastmodifeddt = lastmodifeddt.Date
    lbl.Text = fileBytes.ToString
    lbl2.Text = lastmodifeddt

    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

    now when i sort right i am having:
    Sub SortCommand_OnClick(ByVal Source As Object, ByVal E As
    System.Web.UI.WebControls.DataGridSortCommandEventArgs)
    strSQL = "select FILEID, FILENAME,
    APPSERVICETYPE,LOCATION,FILEREPORT, DESCRIPTION, location2 FROM
    DOWNLOADFILES WHERE (@lower(ORGANISATION)=@lower('" & Orgn & "') or
    @lower(ORGANISATION)='dfe') and FILEREPORT='REPORT' ORDER BY " &
    E.SortExpression()
    GetDeptOfUserLogged()
    bindGrid()
    End Sub

    but here if i sort the caluclated columns then that column doesnt exists
    in db? how can this issue be resolved. can anyone help on this?
    thanks a lot




    --
    Sent via .NET Newsgroups
    http://www.dotnetnewsgroups.com
     
    samir, Dec 21, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?S3VydCBTY2hyb2VkZXI=?=

    calculated column in datagrid question

    =?Utf-8?B?S3VydCBTY2hyb2VkZXI=?=, Mar 23, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    623
    =?Utf-8?B?S3VydCBTY2hyb2VkZXI=?=
    Mar 23, 2005
  2. samir dsf
    Replies:
    1
    Views:
    2,033
    Patrick.O.Ige
    Nov 10, 2005
  3. Replies:
    2
    Views:
    15,979
  4. sush
    Replies:
    1
    Views:
    288
    Victor Bazarov
    Aug 1, 2006
  5. Navin
    Replies:
    1
    Views:
    761
    Ken Schaefer
    Sep 9, 2003
Loading...

Share This Page