473,837 Members | 1,620 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Question on the design of my search, and binding a subordinate DataGrid/Gridview

I have a question about spawning and displaying subordinate list controls
within a list control. I'm also interested in feedback about the design of
my search application. Lots of code is at the end of this message, but I
will start with an overview of the problem.

I've made a content management solution for my work with a decently
structured relational database system. The CMS stores articles. The CMS also
stores related items -- articles and other media related to the primary

I've also implemented a search in ASP.NET using Indexing Services and some
custom properties in Indexing services. The system initates an ADO.NET query
against the Indexing Services engine and then fills a dataset. The dataset
is bound to a grid, displaying the results.

What I want to do is to be able to display any "related articles" as part of
my search results. The related articles would appear beneath a search result
for a primary article. So the results page would look something like


item ID 2001 Dogs and cats can be friends, researchers say
RELATED ARTICLE: John Katz says tech writing
"for the dogs" (item ID 23003)
RELATED AUDIO: Listen to "Sit Ubu, Sit (item
ID 3030430)

item ID 2002 UW researchers find fabulous field of "black smokers"
RELATED AUDO: Harmonic tones (item ID 39395)
RELATED VIDEO: "Old Smokey" fries a crab
(item ID 43838)

I have two questions I need to answer. One relates to the best ways to make
this search performant. The second question relates to the presentation of
subordinate items.

Question #1: Data retrieval and performance question:
I have an idea for a way to design this search so that we don't kill the
database server. A search would initiate two queries and fill two datasets.
One query would fill a dataset of the search results. The second query would
fill a dataset of ALL related articles, including the database IDs of the
related articles, which are relationally linked to the parent article. On
display, the "related articles" dataset would be filtered on the parentID of
the result being iterated. This would be the equivalent of the ADO recordset
..Filter method.

I'm wondering if this a good design, and if so, the syntax and process I'd
use to successively filter a dataset in this way, once on each element in my

Question #2 is suggested by the scenario above. If related articles are
found associated with a given parentID, they need to be displayed in the
results datagrid. A hack-ey way to do this would be to embed a method in the
declarative markup, e.g.
<%#GetRelatedAr ticlesAsAFixedA ndNonBindableSt reamOfHTML(Cont ainer.Dataitem) %>.
The markup would call a function with each iteration of the list control,
and I would have more or less what I want.

A better way would be to have the listcontrol conditionally spawn a second
listcontrol within the itemtemplate if there were related articles, and bind
any "related items" associated with the parentID to that nested listcontrol.
That seems better than the hack described above.

Summarizing, I need to know three things:
+ Is my design any good, or is there a better option reflecting the
hierarchical arrangement of this data? I am using EntitySpaces ORM which
supports a hierarchical model, but that doesn't mean I know how to use it as
well as I should...
+ What's the syntax for filtering and unfiltering an ADO.NET DataSet?
+ What's the syntax/process for spawning nested Datalist controls and
binding my filtered dataset to these child controls (ideas: include an
"empty" datalist control in every instance, or dynamically replace a
placeholder...? )

The code that I'm using to do all this follows...

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

this.lblResultC ount.ForeColor = Color.Black;
int rows = ds.Tables[0].Rows.Count;
this.lblResultC ount.Text = String.Format(" {0} document{1} found
in theXXXX archive that matched your search for <b" +
(Request.QueryS tring["Search"]) + " </b>{2}",
rows, rows == 1 ? " was" : "s were", rows == 0 ? "." : ":");

// 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);
catch (Exception ex)
this.lblResultC ount.ForeColor = Color.Red;
this.lblResultC ount.Text = String.Format(" Unable to retreive a
list " +
"of documents for the specified query: {0}", ex.Message);

this.dgResultsG rid.Visible = false;
this.lblResultC ount.Visible = true;

This is the function that builds the command query:

private string Command
// Construct the base query.
string query = String.Format(@ "
SELECT Rank, Path, DocTitle, Filename, Characterizatio n,
Write, MyContentIDWhic hIsARetrievable CustomPropertyI nIndexingServer
""c:\Inetpub\ww wroot\whatever" "')
WHERE NOT CONTAINS(Path, '""_vti_"" OR "".config"" ')",

// Get the query string and remove all semi-colons, which should
// attempt to run malicious SQL code.

// string queryFromForm =
FixInjection(Re quest.QueryStri ng["Search"].ToLower());
string queryFromForm =
(Request.QueryS tring["Search"].ToLower());

string text = queryFromForm.R eplace(";", "");
// Conditionally construct the rest of the WHERE clause.
string type = "all";

if (text.StartsWit h("\"") && (text.EndsWith( "\"")))
type = "exact";

string fmt = @" AND (CONTAINS('{0}' ) OR CONTAINS(DocTit le,

if (type == "all" || type == "any" || type == "boolean")
string[] words = text.Split(' ');
int len = words.Length;
for (int i = 0; i < len; i++)

string word = words[i];
words[i] = String.Format(@ """{0}""", word);
if (i < len - 1)
words[i] += " AND";

query += String.Format(f mt, String.Join(" ", words));
else if (type == "exact")

query += String.Format(f mt, text);
private void InitializeCompo nent()
this.dbAdapter = new System.Data.Ole Db.OleDbDataAda pter();
this.oleDbSelec tCommand1 = new System.Data.Ole Db.OleDbCommand ();
this.dbConnecti on = new System.Data.Ole Db.OleDbConnect ion();
this.dgResultsG rid.PageIndexCh anged += new
System.Web.UI.W ebControls.Data GridPageChanged EventHandler(th is.dgResultsGri d_PageIndexChan ged);
// dbAdapter
this.dbAdapter. SelectCommand = this.oleDbSelec tCommand1;
// oleDbSelectComm and1
this.oleDbSelec tCommand1.Conne ction = this.dbConnecti on;
// dbConnection
this.dbConnecti on.ConnectionSt ring = "Provider=MSIDX S.1;Data
Source=MyIndexi ngServerDataSou rce";
this.Load += new System.EventHan dler(this.Page_ Load);


The declarative parts of this appear as follows:

<asp:datagrid id=dgResultsGri d runat="server" PageSize="25"
AllowPaging="Tr ue" AutoGenerateCol umns="False" Visible="False"
GridLines="None " Font-Names="Verdana" Font-Size="9pt">
<itemstyle horizontalalign ="Left" verticalalign=" Top">

<headerstyle font-bold="True">


<asp:TemplateCo lumn HeaderText="">
<itemstyle horizontalalign ="Left" verticalalign=" Top">

<itemtemplate >
<p><asp:hyperli nk ID="Hyperlink1 " Font-Bold=True runat="server"
NavigateUrl='<% # GetMyUrl(Contai ner.DataItem)%> '><%#
GetTitle(Contai ner.DataItem)%> </asp:hyperlink>< br>
<i>Published</i<asp:label ID="Label3" Font-Italic = true
runat="server"> <%# GetPubDate(Cont ainer.DataItem) %></asp:label><br />
<asp:label ID="Label2" runat="server"> <%#
GetCharacteriza tion(Container. DataItem)%></asp:label><i><b r />
</asp:TemplateCol umn>

<pagerstyle mode="NumericPa ges">

<td colspan="4">&nb sp;

Thanks in advance for any help you can provide to this (long!) question. I
surely appreciate it.

Feb 2 '07 #1
0 2086

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

Similar topics

by: emma middlebrook | last post by:
Hi Straight to the point - I don't understand why System.Array derives from IList (given the methods/properties actually on IList). When designing an interface you specify a contract. Deriving from an interface and only implementing some of it means something is wrong: either the interface specification is wrong e.g. not minimal or the derivation is wrong e.g. the type can't actually honour this contract.
by: Andrew Robinson | last post by:
Is there any way to accomplish two way data binding in a Details View with a DataSet or DataTable as the DataSource. All I want is to get an updated DataSet or DataTable back from the DetailsView and then handle my updating manually. -Andrew
by: dm1608 | last post by:
Hi - I have a few Classic ASP projects that I would like to convert to ASP.NET 2.0. I've been learning ASP.NET 2.0 for the past few months. One of the ASP projects that I'm converting is a simple HTML form that allows the user to select a few options for a query. Based on their input, I would dynamically build a SQL query to perform a search based on their information. I.E., I may have a listbox that allows them to find a text...
by: maflatoun | last post by:
Hi, I'm wondering if there is a way to bind to datagrid or a gridview the items in an arraylist. These items all have vars such as price, qty..etc? (besides putting in a datagrid or datatable first). ex. ArrayList alShoppingCart = shoppingCart.GetCurrentItems; alShoppingCart contains an array list of Item objects.
by: Antonio | last post by:
With all these new terms, is DataGrid and GridView the same thing?
by: Griff | last post by:
Hi I want to create an n-tier custom server control. The idea is that the control will determine which "view" will be used. By this I mean User A may want the data displayed as a tree-view, User B as a datagrid etc, etc. So, I can envisage that in some circumstances it is using a data bound control and in others a non-data bound control - who knows. In which case,
by: Jami Bradley | last post by:
I'm in need of some design suggestions! We have a fairly large DB with thousands of users accessing data throughout the day. I have been given the task of restructuring a core part of the web application. It will be a design example for the rest of the site and I really want to get it right the first time! Basically we need to present a lot of data to the user. On a single page, we summarize about 5000 rows (grouped so they don't...
by: Mark Olbert | last post by:
Has anyone else noticed that the design-time support for databinding in custom controls in ASPNET2 sucks? At least for GridViews? So far I've spent going on two days trying to get the following simple statements to actually generate something at design-time: gridView = new GridView(); gridView.AutoGenerateColumns = true; gridView.DataSource = ; gridView.DataBind(); I have tried everything I could think of, or read about in four books...
by: jaz215 | last post by:
Hi i have an update page where i update data when a user select a row in the gridview, i also have a search function that displays the data in the gridview all those data that matched the search. my problem is that when i select the data after i search it the selected input would be coming from the previous gridiview look of the data example: standard gridview look Gridview 1strow 2ndrow 3rdrow
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...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
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,...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
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...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.