Nesting repeaters in .NET

Written by ProgrammerTutorials.com


Data repeaters in .NET are very usefull to display database records onto screen. But usually, in a real world situation, you don't have enough functionality with 1 repeater.

Take for example some kind of menu structure. You want to display a category, but every category can have 0 or more subcategories. With 1 repeater, this cannot be done in a simple way. In .NET, you can use nested repeaters for this.

Takerepparttar code below inrepparttar 131673 .aspx file:

... other HTML code ...
<asp:Repeater Runat="server" ID="Category">
<ItemTemplate>

    <a href="category.aspx?category=<%# DataBinder.Eval(Container.DataItem, " rel="nofollow"Category") %>"><%# DataBinder.Eval(Container.DataItem, "Category") %></a><br>
</ItemTemplate>
</asp:Repeater>
... other HTML code ...


Here you will get a list of categories. If you want to add subcategories, one could try to makerepparttar 131674 code below work.

... other HTML code ...
<asp:Repeater Runat="server" ID="Category">
<ItemTemplate>
    <a href="category.aspx?category=<%# DataBinder.Eval(Container.DataItem, " rel="nofollow"Category") %>"><%# DataBinder.Eval(Container.DataItem, "Category") %></a><br>
    <asp:Repeater Runat="server" ID="SubCategory">
    <ItemTemplate>

        <a href="category.aspx?category=<%# DataBinder.Eval(Container.DataItem, " rel="nofollow"SubCategory") %>"><%# DataBinder.Eval(Container.DataItem, "SubCategory") %></a><br>
    </ItemTemplate>
    </asp:Repeater>
</ItemTemplate>
</asp:Repeater>
... other HTML code ...


To make things work, you have to change several things though.
In your .aspx.cs file (or inrepparttar 131675 script area if you are not using codebehind files) you will haverepparttar 131676 following code:


... other c# code ...
DataSet sqlDS = new DataSet();

/* Getrepparttar 131677 categories */
string Query = "select CategoryId, Category from Categories order by Category";

SqlCommand sqlC = new SqlCommand(Query, objConn);
SqlDataAdapter sqlDA = new SqlDataAdapter();
sqlDA.SelectCommand = sqlC;

sqlDA.Fill(sqlDS, "Category"); /// Our dataset containsrepparttar 131678 categories

/* Getrepparttar 131679 subcategories */
string Query = "select SubCategoryId, CategoryId, SubCategory from SubCategories order by SubCategory";
sqlC = new SqlCommand(Query, objConn);
sqlDA.SelectCommand = sqlC;

sqlDA.Fill(sqlDS, "SubCategory"); /// Our dataset containsrepparttar 131680 categories

/* Add a relationship betweenrepparttar 131681 2 tables
In our case, every SubCategory has a CategoryId to pojnt out there parent
*/
ds.Relations.Add("CategoryRelation", ds.Tables["Category"].Columns["CategoryId"], ds.Tables["SubCategory"].Columns["CategoryId"]);



How to get noticed on the Internet

Written by Ieuan Dolby


The World Wide Web was an enormous step for mankind, a step not seen since Neil Armstrong sulliedrepparttar surface ofrepparttar 131671 moon. The idea behindrepparttar 131672 WWW came across as a veritable information highway where documents, data and info could be rapidly sent and accessed by millionsrepparttar 131673 world over. The potential behindrepparttar 131674 web is enormous and even nowrepparttar 131675 scope is not fully utilized. The possibilities for growth, for extended usage, are available and enormous yetrepparttar 131676 system is stagnating and it is very possible that people will soon turn away. The average person seeking information may well return to old-fashioned libraries andrepparttar 131677 good old book to findrepparttar 131678 information that they require ifrepparttar 131679 face and image ofrepparttar 131680 WWW is not altered very soon and in-line with customer demand.

The ability of any user to gain information fromrepparttar 131681 Internet is enormous, simple and with positive results. Butrepparttar 131682 information received is increasingly becoming that which a paying body prescribes and thus is advertisement biased or pointed towardsrepparttar 131683 end purchase of a product. Hotels advertise a city or holiday resort withrepparttar 131684 point of view of potential tourists coming to stay. A detailed description of moon cakes in Taiwan although complete and detailed would certainly be with aim to make people buy some fromrepparttar 131685 store hostingrepparttar 131686 website involved.

Initiallyrepparttar 131687 Internet was heralded as a one-stop point for gaining any type or form of information withrepparttar 131688 click ofrepparttar 131689 mouse. This is certainly true except with regard to loose information that has no affiliation towards an end purchase or a users change of heart. Certainly this type of information is available and millions of websites exist but unless a user has prior information on how to access this site thenrepparttar 131690 chance of it being found amongstrepparttar 131691 masses is minimal. Most web users find or locate information by using a search engine. Most web users input their request and wait for results to come up as prescribed and ordered byrepparttar 131692 search engine system. If for example a request was entered for “travel tales onrepparttar 131693 sea” many, possibly thousands of choices will appear in return. Number one inrepparttar 131694 pole position will probably be Amazon.com who feels certain that anybody looking for a story would probably find it amongst their collection – naturally obtainable at a price. The next onrepparttar 131695 list might be Ebay who feel that certain travel products might appeaserepparttar 131696 searcher or it might be goarticles.com an articles selling service who would assume that travel tales ofrepparttar 131697 sea would be somebody looking to buy such from them and for their own use.

Certainly each and every result that is produced onrepparttar 131698 first page would pointrepparttar 131699 user towards large companies who are selling an item of one sort or another. The user though may in fact just want to read some Travel Tales ofrepparttar 131700 Sea without having to fork out cash or to issue his/her credit card information overrepparttar 131701 Internet.

Inrepparttar 131702 bowels ofrepparttar 131703 search results in pages that are covered in dust will reside some very comprehensive and useful websites, eg: http://www.seadolby.com a website that is filled with free and in-depth Travel Tales ofrepparttar 131704 Sea. The possibility of any user keeping interest long enough to get to this web site listing is minimal and long before it is reachedrepparttar 131705 user has either fallen asleep or entered another search on a different note. In shortrepparttar 131706 average user does not get pastrepparttar 131707 first page of a search engines results and probably not pastrepparttar 131708 first three that come up: e.g. amazon.com, ebay.com and goarticles.com

Although not-for-profit informational web sites are many and filled with amazing and detailed info these sites ability to gain attention onrepparttar 131709 world stage is difficult unless money is poured in to boost their ratings and rank positions onrepparttar 131710 search engine results. Nowadays many search engines have enteredrepparttar 131711 pay-per-click arena with companies putting forward money to buy keywords that will most likely be used to boost their website. Some company buysrepparttar 131712 word “Travel” and this word is then basically lost forever torepparttar 131713 lone free-for-all info site who cannot afford to pay money to boost their popularity.

The art of advertising and paying for positions on search engines is only available torepparttar 131714 sites that can affordrepparttar 131715 exorbitant fees. Should a lone site owner who has built his site-up decide to fork out of his own pocketrepparttar 131716 money to boost his ratings this will only be achieved on one or two search engines or directories andrepparttar 131717 amount required to compete withrepparttar 131718 mega-sites is far beyond any hobbyist can afford. Naturallyrepparttar 131719 ability to submit ones site on free inclusion pages and directories is available but asrepparttar 131720 webmaster and author behind Seamania found out, so much energy and time is spent on advancingrepparttar 131721 ratings of his site that not enough time is given torepparttar 131722 writing of travel tales ofrepparttar 131723 sea, which of course isrepparttar 131724 basis and sole point behindrepparttar 131725 website inrepparttar 131726 first place.

Cont'd on page 2 ==>
 
ImproveHomeLife.com © 2005
Terms of Use