473,661 Members | 2,465 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
{
get
string query = String.Format(@ "
SELECT Rank, VPath, DocTitle, Filename, Characterizatio n,
Write, uwnpubdate,uwnv olume,uwnnumber , uwncontentcateg ory
FROM SCOPE('SHALLOW TRAVERSAL OF
""c:\Inetpub\ww wroot\ni\search \indexes\myInde x""')
WHERE NOT CONTAINS(VPath, '""_vti_"" OR "".config"" ')",
"/search/indexes/uweek");
... [other configure-my-query-code ]
.....

private void Search()
{
// Create a new DataSet and fill it.
try
{
this.dbAdapter. SelectCommand.C ommandText = Command;
DataSet ds = new DataSet("Result s");
this.dbAdapter. Fill(ds);

....
// Bind the resulting DataSet.
this.dgResultsG rid.DataSource = ds;
this.dgResultsG rid.DataBind();

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

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

<ItemTemplate >
<p>
<asp:HyperLin k ID="Hyperlink1 " runat="server" NavigateUrl='<% #
GetUwnewsUrl(Co ntainer.DataIte m)%>'><%#
GetTitle(Contai ner.DataItem)%> </asp:HyperLink>< br>
<i>Published <asp:Label ID="Label3" Text="<%#
GetPubDate(Cont ainer.DataItem) %>" runat="server" /| Vol. <asp:Label
ID="Label4" runat="server"> <%# GetVolume(Conta iner.DataItem)% ></asp:Label>,
No. <asp:Label ID="Label5" runat="server"> <%#
GetNumber(Conta iner.DataItem)% ></asp:Label></i><br />
<asp:Label ID="Label2" runat="server"> <%#
GetCharacteriza tion(Container. DataItem)%></asp:Label><br />
</ItemTemplate>
The inline functions are calling code similar to this:

protected object GetVolume(objec t 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.

-KF
Jan 17 '07 #1
1 1439
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 programmaticall y 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?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

=============== =============== =============== =====

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

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
http://msdn.microsoft.com/subscripti...t/default.aspx.

=============== =============== =============== =====

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

4
2318
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
22
4137
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) { return -1; } else
2
1775
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 noticed that in .NET applications Windows widgets like the DataGrid are often directly bound to a DataSet Object. For me this means essentially a 2 tier architecture instead of a 3 tier architecture. I am used to seperating the application into 3 tiers:...
2
13052
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 small steps. Right now, I'm just trying to attach a ComboBox to a dataset that's in my class module. In the class, I call a Stored Procedure. I know how to set up the connection, command, adapter, and dataset, what I'm having a problem with is,...
6
1364
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 as "Please enter a name." It seems like the best place to put them, from the programmer's point of view, is in the business layer. That way the same validations work for either Winforms or Webforms. Also, if I redo my interface later, I don't...
1
938
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 have several DLL classes that call the DAAB and receive datasets on return. These datasets are then passed back to calling BLL classes and then onto the Presentation layer which is ASP.NET.
0
1290
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 at Design Time, you are restricted to using one of the 5 xxxDataSource controls. The data in our websites are usually obtained via a set of webservices and are contained in a set of strongly typed relational DataSets.
15
2155
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 access layers, should I use static methods? Or, should I code the classes so that they have to be instantiated? I've seen examples of both, and I'm not sure which is the "preferred" or "best" way. Thanks.
0
1146
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 first concern would be to separate the business logic code from data contener : the new code would look like that : LineItemBusinessComponent.Delete(LineItemBusinessEntity) Exposing CRUD component isn't the best thing to do because your presentation...
0
8428
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8341
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8542
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8630
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6181
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4343
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2760
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1984
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1740
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.