G
Guest
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, Characterization,
Write, uwnpubdate,uwnvolume,uwnnumber, uwncontentcategory
FROM SCOPE('SHALLOW TRAVERSAL OF
""c:\Inetpub\wwwroot\ni\search\indexes\myIndex""')
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.CommandText = Command;
DataSet ds = new DataSet("Results");
this.dbAdapter.Fill(ds);
....
// Bind the resulting DataSet.
this.dgResultsGrid.DataSource = ds;
this.dgResultsGrid.DataBind();
// 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:
<ItemTemplate>
<p>
<asp:HyperLink ID="Hyperlink1" runat="server" NavigateUrl='<%#
GetUwnewsUrl(Container.DataItem)%>'><%#
GetTitle(Container.DataItem)%></asp:HyperLink><br>
<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 />
</ItemTemplate>
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.
-KF
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, Characterization,
Write, uwnpubdate,uwnvolume,uwnnumber, uwncontentcategory
FROM SCOPE('SHALLOW TRAVERSAL OF
""c:\Inetpub\wwwroot\ni\search\indexes\myIndex""')
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.CommandText = Command;
DataSet ds = new DataSet("Results");
this.dbAdapter.Fill(ds);
....
// Bind the resulting DataSet.
this.dgResultsGrid.DataSource = ds;
this.dgResultsGrid.DataBind();
// 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:
<ItemTemplate>
<p>
<asp:HyperLink ID="Hyperlink1" runat="server" NavigateUrl='<%#
GetUwnewsUrl(Container.DataItem)%>'><%#
GetTitle(Container.DataItem)%></asp:HyperLink><br>
<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 />
</ItemTemplate>
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.
-KF