|
I have a problem getting the right data from the database.
I have two tables named "Category" and "Items". Under one category, there can be multiple items.
table for category looks like:
catagory_ID | catagory_Name | catagory_Description
and the table for item looks like:
item_ID | cat_ID | item_Name | item_Description
Here category_ID and item_ID are unique keys and cat_ID is the foreign key which is the category_ID.
now i want the query which gives the list of data under typical category in the list format.
e.g if Book is the category Name and book_name1,book_name2,book_name3 are the items under category, it should look like
Book
book_name1
book_name2
book_name3
how to do that? Well i can get something like this:
Book book_name1
Book book_name2
Book book_name3
but I want the category just once in the output..
I am using asp.net with c# and sql server..
code is:
<asp:Repeater runat="server" id="Repeater1">
<HeaderTemplate>Categories<br /></HeaderTemplate>
<ItemTemplate>
<b><%# DataBinder.Eval(Container.DataItem, "category_Name") %></t></b>
<br><%# DataBinder.Eval(Container.DataItem, "item_Name") %></br>
</ItemTemplate>
</asp:Repeater>
suchita
|
|
|
|
|
SayamiSuchi wrote: I want the category just once in the output
Then only put it there once. You control the output.
|
|
|
|
|
i tried the nested itemTemplate one for category and one for items but it gave the same output. Didn't work that way..
suchita
|
|
|
|
|
SayamiSuchi wrote: nested itemTemplate
I have no idea what you're talking about. I just suspect you'll need to do some actual programming. (You'll be better for it.)
|
|
|
|
|
ok. Let me explain again. I have two tables named category and item. Below are the fields of category and item respectively.
catagory_ID | catagory_Name | catagory_Description
and the table for item looks like:
item_ID | cat_ID | item_Name | item_Description
Here category_ID and item_ID are unique keys and cat_ID is the foreign key which is the category_ID.
I wanted to show the category and item in the format like below:
Here there should be only one category but for each category, there can be several items under that.
e.g if Book is the category Name and book_name1,book_name2,book_name3 are the items under category, it should look like
Book
book_name1
book_name2
book_name3
I am getting the output like shown below: Here I am having category name also repeatedly which i don't want.
Book book_name1
Book book_name2
Book book_name3
I want the category just once in the output..
I am using asp.net with c# and sql server..
code is:
<asp:Repeater runat="server" id="Repeater1">
<HeaderTemplate>Categories<br /></HeaderTemplate>
<ItemTemplate>
<b&><%# DataBinder.Eval(Container.DataItem, "category_Name") %></t></b>
<br><%# DataBinder.Eval(Container.DataItem, "item_Name") %></br>
</ItemTemplate>
</asp:Repeater>
suchita
|
|
|
|
|
Yes, but you don't seem to want to do any work to achieve your goals.
I don't do ASP.net; I write real programs.
|
|
|
|
|
I tried nested itemTemplate too but it gave the same output..
suchita
|
|
|
|
|
I don't do asp but it looks to me like you need a repeater within a repeater.
In pseudoish code something like:
asp:Repeater
HeaderTemplate
ItemTemplate
Data - category name
asp:Repeater
ItemTemplate
Data - item name
/ItemTemplate
/asp:Repeater
/ItemTemplate
/asp:Repeater
Whether or not you can do that I haven't a clue - but that looks like the logic you need.
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
The only valid measurement of code quality: WTFs/minute.
|
|
|
|
|
yes. I tried that way too but the data inside the nested repeater doesn't show up.
suchita
|
|
|
|
|
hi
how to call published web pages from windows services that I create
thanks
|
|
|
|
|
|
You can use a System.Net.HttpWebRequest from any type of application.
|
|
|
|
|
Hi
Currently considering to learn som C# to use professional at work. I've been looking at courses from "www.learndevnow.com" and "www.learnvisualstudio.net". Any one with experience with these or have any recommendations.
/Eiel
|
|
|
|
|
|
I have no experience with online programming courses, but I'm a bit suspicious about them (I'm talking about payd courses, not about tutorials of course). Expecially if you are already experienced with programming in any other language, I think the best is to buy a good book, and make experiments with sample application (you can download plenty of them from Code Project).
Cheers,
Sauro
|
|
|
|
|
I second that.
|
|
|
|
|
Good post!
|
|
|
|
|
Online programming courses suck. Many of which will teach you a way to do something that is the wrong way, skipping fundamentals which will later be harder to learn. The easiest way to learn and master programming is to start with a task. A common one that new programmers often choose is the task of making an encrypted, peer-peer chat application. It covers all of the bases and is just hard enough to teach you something good. Also, a beginners book can be very helpful because you can flip through it rapidly.
|
|
|
|
|
Ennis Ray Lynch, Jr. wrote: will teach you a way to do something that is the wrong way
Of course, the books I've seen do that too.
|
|
|
|
|
You are correct. However, the books at least have to go through publishing whereas online tutorials are often copy and pasted outright theft of others work with no real knowledge by the other. Or worse, in online tutorials, the Author usually starts with an overly complex example to demonstrate a trivial task.
|
|
|
|
|
I also recommend starting with a book. But I found that it wasn't enough for me so I took a course and it made a lot of difference. The ability to speak with and get feedback from someone who knows the subject can be quite valuable.
At the moment I find myself having to learn [the .net language that shall not be named] so I will likely buy a book today.
|
|
|
|
|
I recommend Option Strict On as the very first line.
|
|
|
|
|
I shall endeavor to check that that is in their coding standards... if they have any.
|
|
|
|
|
I added it to my vbc.rsp file -- putting it in every file is just silly.
|
|
|
|
|
that turns you into an advanced VB jockey.
|
|
|
|