473,405 Members | 2,210 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

subset of data using dataview??

Dear sir,

New to ASP.NET, help will be appreciated.

I need to create a XML file for product feed. In our business, one product
always belongs to more than 1 categories. I need to have a XML file like.
<product id = "105">
<Name>whatever</Name>
<Categories>
<Category name = "Category1"/>
<Category name = "Category2"/>
.....
</Categories>
</product>

I can use a dataset which get the data from product table. However, my
question is that how can I get a sub set data of category. The category
rows varies depends on the product id. I am thinking to use dataview filter.
The following is my code.
.......
dvCategory = New DataView(dtCategory)
strView = "ProductId='"&r("ProductId")&"'"
dvCategory.RowFilter= strView
For Each rCat in dvCategory.Table.Rows
Writer.WriteStartElement("category")
Writer.WriteAttributeString("name",
rCat("CatName")&r("ProductId"))
Writer.WriteEndElement()
Next
....

It will write out all the categories instead of only those categories this
product belongs to. Any idea what did I do wrong or how can I achieve this??

Thanks in advanced.

Guoqi Zheng
Tel: 0031-23-5343545
http://www.meetholland.com
Nov 18 '05 #1
2 1487
This is because you are still grabbing all the rows from the underlying
table. The underlying table never changes, but the dataview can filter which
rows you see.

You should be looking at the Item property of the DataView to get each row
as filtered from the dataview instead.

"Guoqi Zheng" <no@sorry.com> wrote in message
news:ul**************@TK2MSFTNGP12.phx.gbl...
Dear sir,

New to ASP.NET, help will be appreciated.

I need to create a XML file for product feed. In our business, one product
always belongs to more than 1 categories. I need to have a XML file like.
<product id = "105">
<Name>whatever</Name>
<Categories>
<Category name = "Category1"/>
<Category name = "Category2"/>
.....
</Categories>
</product>

I can use a dataset which get the data from product table. However, my
question is that how can I get a sub set data of category. The category
rows varies depends on the product id. I am thinking to use dataview filter. The following is my code.
.......
dvCategory = New DataView(dtCategory)
strView = "ProductId='"&r("ProductId")&"'"
dvCategory.RowFilter= strView
For Each rCat in dvCategory.Table.Rows
Writer.WriteStartElement("category")
Writer.WriteAttributeString("name",
rCat("CatName")&r("ProductId"))
Writer.WriteEndElement()
Next
....

It will write out all the categories instead of only those categories this
product belongs to. Any idea what did I do wrong or how can I achieve this??
Thanks in advanced.

Guoqi Zheng
Tel: 0031-23-5343545
http://www.meetholland.com

Nov 18 '05 #2
Hi,

For Each rCat in dvCategory.Table.Rows
Writer.WriteStartElement("category")
Writer.WriteAttributeString("name",
rCat("CatName")&r("ProductId"))
Writer.WriteEndElement()
Next
....

It will write out all the categories instead of only those categories this
product belongs to. Any idea what did I do wrong or how can I achieve

this??

You should loop through DataView' DataRowView:
foreach (DataRowView drv in dv)

Write...(drv["name"]);
--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com
Nov 18 '05 #3

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

Similar topics

1
by: J | last post by:
This works well for binding a Dataset (created from an XML file) to a DataGrid for the entire 'page' table. However I would like to only grab a few rows from the 'page' table (like: select id,...
1
by: Tim | last post by:
Hi I am implementing some printing in C# and I need to get the data for it. I am using a datagrid. I can sort the data and filter it. I want to get a datatable of only the data visible in the...
6
by: Patrick.O.Ige | last post by:
Hi guys, Just using these small snippet below using Datalist with sorting! But it appears i can see no Data on the screen when compiled with Visual Studio .Net! With WebMatrix its running fine!:)...
0
by: MichaƂ Januszczyk | last post by:
Is it possible somehow to retreive {data Key Value} based on clicked {datagrid item index} ? Now i'm trying to do this in the following way, but with no effect. Now, Instead of getting value...
5
by: tshad | last post by:
Is there a way to carry data that I have already read from the datagrid from page to page? I am looking at my Datagrid that I page through and when the user says get the next page, I have to go...
4
by: Atley | last post by:
I am using VB.net Ent Arch 2003. I have a dataset that was made through the wizard to create a Windows Data Form I have a DataGrid to show/edit the table from my DataSet. I want to: Be...
7
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I...
9
by: Kay | last post by:
Hi all, Could you tell me the best way to add a blank item(as first item) in a data binded combo box? Because I think I didn't do it right and it generate an error if the second item(after the...
18
by: Brock | last post by:
I'm trying to develop a web service to expose an XML file for product manufacturers for a client application to consume and populate a datagrid on the consuming end. I have successfully tested...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...

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.