473,394 Members | 1,828 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,394 software developers and data experts.

Searching XML adding found item to DataGridView

133 100+
Hello Folks,
I am searching a XML file for <Asset_Number> and then
adding all children to DataGridView1,
i can search but i dont know how to add item to the DataGridView
Also my datagridview columns are created from a txt file


this is what i have.....

this is my XML
<?xml version="1.0" standalone="yes"?>
<DocumentElement>
<items>
<Description>Description</Description>
<Asset_Number>Asset Number</Asset_Number>
<Asset_Type>Asset Type</Asset_Type>
<Location>Location</Location>
</items>
<items>
<Description>Laminator</Description>
<Asset_Number>MOA81</Asset_Number>
<Asset_Type>Electrical</Asset_Type>
<Location>ADMINISTRATION OFFICE</Location>
</items>
</DocumentElement>

Expand|Select|Wrap|Line Numbers
  1.     Dim items As DataSet = New DataSet()
  2.     Dim count As Integer
  3.     Dim a As Integer
Expand|Select|Wrap|Line Numbers
  1.         items.ReadXml((Application.StartupPath) & "\electrical_DB.xml", XmlReadMode.Auto)
  2.         count = items.Tables(0).Rows.Count
  3.         Call find()
Expand|Select|Wrap|Line Numbers
  1.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2.         'XML search
  3.         Dim b As Integer
  4.         For b = 0 To (count - 1)
  5.             If items.Tables(0).Rows(b).Item("Asset_Number").ToString.ToUpper Like ((txtBarCode.Text.ToUpper) & "*") Then
  6.                 a = b
  7.                 Call find()
  8.                 Exit For
  9.             End If
  10.         Next
  11.     End Sub
Expand|Select|Wrap|Line Numbers
  1.     Sub find()
  2.         'this is where im stuck
  3.         'i want the whole found node displayed in DataGridView1
  4.         ' but this doesnt work
  5.         DataGridView1.datasource = items.Tables(0).Rows(a).Item("Asset_Number")
  6.     End Sub
any help would be greatly appreciated , please forgive me as i am just
learning
Thanks in advanced
Gobble.
Jul 23 '09 #1
1 1874
Frinavale
9,735 Expert Mod 8TB
While looking into your problem I came an interesting fact that I was unaware of until now. Apparently you can use ADO.NET to fill a DataSet. Check out this article for more information.

A DataSet contains a bunch of tables. A table can be used as a data source for the DataGridView control....

I've never done this before myself, but you should look into whether or not XSL can help you to filter the XML results into what you want.

-Frinny
Jul 27 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Art | last post by:
Hi everyone I was hoping someone might be able to help me with this. I'm just starting to try to work with MS Access tables through VB.net. In Access I can take an existing table and add a new...
6
by: dbuchanan | last post by:
Hello, Is this a bug? Is there some kind of work around? I want to add default values for a few columns in my datagridview I found the "DefaultValuesNeeded" event for the datagridview I...
7
by: manstey | last post by:
Hi, I often use: a='yy' tup=('x','yy','asd') if a in tup: <...> but I can't find an equivalent code for:
3
by: sklett | last post by:
I'm changing from a DataGrid to a DataGridView and have run across a problem. The items that are bound to the DataGrid have an int Property that represents a primary key of a lookup table in my...
0
by: romerve | last post by:
Hello, I am interested on how to edit/view an item or record selected from a DataGridView. The SQL queries for some data including the ID which is not visible on the GridView. I want to be...
1
by: j_depp_99 | last post by:
I would like to know what would be the best way to count the nodes accessed while searching for an item in a binary search tree. I have to keep a tally for each item I search for. I have included...
4
by: jodleren | last post by:
Hi! I wonder, which way to do this fastest. I have a disk, where I need to search for a file or directory. I do it recursively, meaning that I start from the top dir, then I add all...
1
by: Andrus | last post by:
I need to create WinForms DataGridView column which shows spaces between thousands. I have found that MaskedTextBox Mask property supports this I tried to add column to DataGridView using ...
3
by: jehugaleahsa | last post by:
Hello: I am binding a DataGridView with a BindingList<T>, where T is a custom business object that implements INotifyPropertyChanged. When you bind a DataGridView to a DataTable, it has this...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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,...
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...

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.