473,233 Members | 1,438 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,233 software developers and data experts.

casting question: sorting strings as dates in either dataset or in the presentation layer?

I'm querying Index Server to return search results, both regular properties
and some custom properties I've created. Index Server has this preference
for thinking about information as strings rather than datatypes.If you
really work at it, you can configure Index Server to treat the data as, say,
sortable DateTime datatypes, or integer datatypes. But I'm finding this a
huge pain in the butt, and it bothers me that I'm attaching a bunch of
custom configurations to the server just to get a sort working. It would be
better if this happens in the application.

I'm wondering if I could "fix" my stringy data in either the data layer or
somewhere in the presentation layer: at some point, I want ASP.NET or
ADO.NET to recast the date strings to real sortable datatypes. I'm hoping
someone can give me some guidance on the easiest way to make this happen.

Here's the rough version of what I've got going; much was originally pulled
from the code project. I need some counsel and maybe some code regarding the
best place to make the casts from string data to datatime data, and I need
to know how to implement a reverse chrono sort either using the in-memory
instance of the data, or maybe on the grid.

private string Command
string query = String.Format(@"
SELECT Rank, VPath, DocTitle, Filename, Characterization,
Write, uwnpubdate,uwnvolume,uwnnumber, uwncontentcategory
""c:\Inetpub\wwwroot\ni\search\indexes\myIndex ""')
WHERE NOT CONTAINS(VPath, '""_vti_"" OR "".config""')",
... [other configure-my-query-code ]

private void Search()
// Create a new DataSet and fill it.
this.dbAdapter.SelectCommand.CommandText = Command;
DataSet ds = new DataSet("Results");

// Bind the resulting DataSet.
this.dgResultsGrid.DataSource = ds;

// If all was bound well, display the DataGrid.
this.dgResultsGrid.Visible = (rows 0);

The itemtemplates on the grid use functions to call the data they need:

<asp:HyperLink ID="Hyperlink1" runat="server" NavigateUrl='<%#
<i>Published <asp:Label ID="Label3" Text="<%#
GetPubDate(Container.DataItem)%>" runat="server" /| Vol. <asp:Label
ID="Label4" runat="server"><%# GetVolume(Container.DataItem)%></asp:Label>,
No. <asp:Label ID="Label5" runat="server"><%#
GetNumber(Container.DataItem)%></asp:Label></i><br />
<asp:Label ID="Label2" runat="server"><%#
GetCharacterization(Container.DataItem)%></asp:Label><br />
The inline functions are calling code similar to this:

protected object GetVolume(object value)
string volume = DataBinder.Eval(value, "uwnvolume") as string;
if (volume != null && volume.Length 0) return volume;

return DataBinder.Eval(value, "uwnvolume");
TIA for any help you can offer.

Jan 17 '07 #1
1 1421
Hello KF,

From your description, you're using .NET code to query the IIS indexing
service content and display then through web page. since all the columns in
the indexing content are queried out as string/text, you're wondering how
to convert those typed values(such as Datetime, int) into their actual type
values, correct?

Based on my research, for the .NET DataSet/DataTable, if you want to make
the column values in each row be converted to their actual type, the
original source data should be in XML format which conforms to a certain
dataset schema. For your scenario, your data is some simple formatted text
content, the DataSet/DataTable can not automatically convert it.

One way to convert those data is you first load the content into a
DataSet/DataTable, then create a new DataTable with columns explicitly
defined as those actual type(such as DateTime, Int ....). After that, you
can programmatically loop through the original datatable, and explicitly
convert the certain colums value into their actual format and add the new
values into the new typed DataTable. For example, for datetime value, you
can use DateTime.Parse, for integer, you can use Int32.Parse.... But such
approach is quite expensive and will hit your application's performance.

How do you think on this?


Steven Cheng

Microsoft MSDN Online Support Lead


Get notification to my posts through email? Please refer to

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at


This posting is provided "AS IS" with no warranties, and confers no rights.

Jan 17 '07 #2

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

Similar topics

by: Kevin Davis | last post by:
Hello, I would like to know if Javascript can do the following thing. I have a list of files and they have the following names: 05 Jun 03 04 Jun 03 03 Jun 03 02 Jun 03
by: mike | last post by:
If I had a date in the format "01-Jan-05" it does not sort properly with my sort routine: function compareDate(a,b) { var date_a = new Date(a); var date_b = new Date(b); if (date_a < date_b)...
by: hans | last post by:
Hi! I am new to .NET (coming from Java). We have to implement a desktop application which extracts data from a database, does some analysis, filtering etc. and displays the results. I have...
by: JS | last post by:
I'm trying to create a data layer and having problems returning a DataSet from my code that's in a class module. Please forgive me. I'm new to C# (VB'er). I decided to create my data layer in...
by: Michael Rodriguez | last post by:
If you're using a standard 3-tiered architecture, i.e. Data Layer-> Business Layer->Presentation Layer, where is the recommended place to put data validations? Specifically, data validations such...
by: richilli | last post by:
Hello I am getting a little lost in the N-Tier business. Let me explain what I have so far. I am using the Data Access Application Block to execute my SQL stored procedures on the backend. I...
by: Simon Gregory | last post by:
I am currently attempting to figure out how the new databinding stucture works in ASP.NET 2.0 after working with v1.0 & v1.1 for several years. It seems that if you wish to do set up databinding...
by: dn | last post by:
I'm starting an n-tier application with an ASP.NET 2.0 presentation layer, a business layer, a data access layer, and a SQL Server 2005 database, and I have a question. In the business and data...
by: =?Utf-8?B?SmVhbi1GcmFuY29pcyBCcmV0b24=?= | last post by:
"siddharthkhare@hotmail.com" wrote: The context is important in this kind of design concern : I assume there's a lot of user and that application will evolve to add richer functionality. My...
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.