very urgent-sorting not working

S

samir dsf

hi
i am using a caluculated column to sort the datagrid; when i form the
query it takes that new column and hence gives me an error 'Invalid
column name'.

here is what i am doing:
in my ascx page:
<asp:TemplateColumn HeaderText="Last Modified"
HeaderStyle-CssClass="SubHead" SortExpression="lbl2">
<ItemTemplate>
<asp:Label Runat="server" ID="lblMdDate" CssClass="SubHead"></asp:Label>
</ItemTemplate>
</asp:TemplateColumn>

in dgFiles_ItemDataBound i am calculatating the column value
Dim lastmodifeddt As Date = File.GetLastWriteTime(FilePath & filename)
lastmodifeddt = lastmodifeddt.Date
lbl.Text = fileBytes.ToString
lbl2.Text = lastmodifeddt

so lastmodifeddt is my calulated value which i can see in the datagrid

here is my bindgrid function

GoToDBOpenConn()
myDa.SelectCommand = New System.Data.OleDb.OleDbCommand(strSQL,
objConnection)
myDa.Fill(myDS)
myDS.Tables(0).Columns.Add("lastmodifeddt")
Dim objView As New DataView(myDS.Tables(0))
objView.Sort = "lastmodifeddt ASC"
dgFiles.DataSource = objView
dgFiles.DataBind()

and here is my sort funtion:
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('" & Session("Orgn") & "') or
@lower(ORGANISATION)='rty') and FILEREPORT='REPORT' ORDER BY " &
E.SortExpression()
bindGrid2()

End Sub



can anyone help me what i m missing. their is something wrong i am doing
... but not able to make out. would be really grateful if somebody could
help me on this.

thanks a lot
 
I

intrader

hi
i am using a caluculated column to sort the datagrid; when i form the
query it takes that new column and hence gives me an error 'Invalid
column name'.

here is what i am doing:
in my ascx page:
<asp:TemplateColumn HeaderText="Last Modified"
HeaderStyle-CssClass="SubHead" SortExpression="lbl2">
<ItemTemplate>
<asp:Label Runat="server" ID="lblMdDate" CssClass="SubHead"></asp:Label>
</ItemTemplate>
</asp:TemplateColumn>

in dgFiles_ItemDataBound i am calculatating the column value
Dim lastmodifeddt As Date = File.GetLastWriteTime(FilePath & filename)
lastmodifeddt = lastmodifeddt.Date
lbl.Text = fileBytes.ToString
lbl2.Text = lastmodifeddt

so lastmodifeddt is my calulated value which i can see in the datagrid

here is my bindgrid function

GoToDBOpenConn()
myDa.SelectCommand = New System.Data.OleDb.OleDbCommand(strSQL,
objConnection)
myDa.Fill(myDS)
myDS.Tables(0).Columns.Add("lastmodifeddt")
Dim objView As New DataView(myDS.Tables(0))
objView.Sort = "lastmodifeddt ASC"
dgFiles.DataSource = objView
dgFiles.DataBind()

and here is my sort funtion:
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('" & Session("Orgn") & "') or
@lower(ORGANISATION)='rty') and FILEREPORT='REPORT' ORDER BY " &
E.SortExpression()
bindGrid2()

End Sub



can anyone help me what i m missing. their is something wrong i am doing
.. but not able to make out. would be really grateful if somebody could
help me on this.

thanks a lot
Seems to me that the problem is with your select statement; this assumes
that the db already has the calculated column --> this may be reason for
your problem.

What I would do is create a DataSet and sort it there.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top