none
I can not load a XML file into DataGridView RRS feed

  • Question

  • Hi all of you,

    primary platform is Framework 2.0

    My datagridview shows nothing after the assignment of the dataset...

     Public dtsBooks As New Books
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Cargar_xml()
        End Sub
        Public Sub Cargar_xml()
            dtsBooks.ReadXml("C:\puesto\Books\Books\ProductAffiliatesFeed.xml")
            Me.DataGridView1.DataSource = dtsBooks.Tables("XMLProductFeed")
    
        End Sub


    Enric

    Monday, June 4, 2012 9:11 AM

Answers

  • BOOKS looks like a customised datatype, can you show us what is it made like

    For the trail purpose just declare dtsbooks as a simple dataset and then assing and let us know the results


    Abhinav

    • Marked as answer by Enric Vives Monday, June 4, 2012 10:11 AM
    Monday, June 4, 2012 9:30 AM
  • Ahaan Ok, not to sure whats happening needs to see what exactly you have done on the aspx, have you used the default databinding of datgrid view,

    try giving the dtsBooks.ReadXml("C:\puesto\Books\Books\ProductAffiliatesFeed.xml")
           
    Me.DataGridView1.DataSource = dtsBooks.Tables("XMLProductFeed")
            
    DataGridView1.DataBind();

    as the function code,

    I presume your dataset is populating properly did you put a debugger, and check the datatable is populated properly XMLProductFeed?


    Abhinav

    • Marked as answer by Enric Vives Monday, June 4, 2012 10:11 AM
    Monday, June 4, 2012 9:50 AM
  • first chaeck that yo uare getting to the instruction by putting a break point on the line. YOu may be missing the form_Load Event.  You need to go to the form and look at the properties.  then press the lightning bolt in the property box (at the top) and use the pulldown to select your load event.

    If this isn't the problem then your code isn't executing all the proper events.  What template or webpage are you using as an example for your project.


    jdweng

    • Marked as answer by Enric Vives Monday, June 4, 2012 10:11 AM
    Monday, June 4, 2012 9:53 AM

All replies

  • BOOKS looks like a customised datatype, can you show us what is it made like

    For the trail purpose just declare dtsbooks as a simple dataset and then assing and let us know the results


    Abhinav

    • Marked as answer by Enric Vives Monday, June 4, 2012 10:11 AM
    Monday, June 4, 2012 9:30 AM
  • hi AB82,

    thanks for your answer

    Books is the name of my dataset.

    XMLProductFeed is the name of my datatable created with the same number of columns of my XML file.

    I would like to remark that for all the fields created in my datatable I have not created their datatypes.


    Enric

    Monday, June 4, 2012 9:42 AM
  • Ahaan Ok, not to sure whats happening needs to see what exactly you have done on the aspx, have you used the default databinding of datgrid view,

    try giving the dtsBooks.ReadXml("C:\puesto\Books\Books\ProductAffiliatesFeed.xml")
           
    Me.DataGridView1.DataSource = dtsBooks.Tables("XMLProductFeed")
            
    DataGridView1.DataBind();

    as the function code,

    I presume your dataset is populating properly did you put a debugger, and check the datatable is populated properly XMLProductFeed?


    Abhinav

    • Marked as answer by Enric Vives Monday, June 4, 2012 10:11 AM
    Monday, June 4, 2012 9:50 AM
  • first chaeck that yo uare getting to the instruction by putting a break point on the line. YOu may be missing the form_Load Event.  You need to go to the form and look at the properties.  then press the lightning bolt in the property box (at the top) and use the pulldown to select your load event.

    If this isn't the problem then your code isn't executing all the proper events.  What template or webpage are you using as an example for your project.


    jdweng

    • Marked as answer by Enric Vives Monday, June 4, 2012 10:11 AM
    Monday, June 4, 2012 9:53 AM
  • Abhinav, it is a winform application.

    DataBind method doesn't exist only I see "DataBindings"

    I enclosed my code in a try..catch but I do not get any error..

    Try
                dtsBooks.ReadXml("C:\puesto\Books\Books\ProductAffiliatesFeed.xml")
                Me.DataGridView1.DataSource = dtsBooks.Tables("XMLProductFeed")
                Me.DataGridView1.Refresh()
                Me.Refresh()
    Catch ex As Exception

    End Try


    Enric

    Monday, June 4, 2012 10:04 AM
  • hi,

    Finally I've created in run-time a dataset instead of a dataset typed and everything works properly!!


            Dim ds As New DataSet

            ds.ReadXml(My.Application.Info.DirectoryPath & "\ProductAffiliatesFeed.xml")
            Me.DataGridView1.DataSource = ds.Tables(0)

    Thanks a lot


    Enric

    Monday, June 4, 2012 10:46 AM