Bind xml data as item source in GridView

2 posts, 0 answers
  1. Ramkrishn
    Ramkrishn avatar
    2 posts
    Member since:
    Sep 2011

    Posted 07 Oct 2011 Link to this post

    Hi,
     I'm using Telerik GridView. I have an issue regarding data binding in GridView. according to my requirement I have a Stored Procedure i my database and it returning me datas and i need to bind that data in GridView bt my problem is that i don't have any fix columns. my columns name changes according to month and also columns counter change so i can't bind columns. so resolving this i created xdocument and fill all datas in it and columns name.
     here is my xDocument.

    <?xml version="1.0" encoding="utf-8" ?>
    <ROOT>
      <ITEM  HIDE_M_SYS_CD_ITEM="70" ITEM_CATEGORY=">50 HP" ITEM_NAME="0252PY01(0252PY01)" _29-Aug-2011="2" _19-Sep-2011="2" ></ITEM>
      <ITEM  HIDE_M_SYS_CD_ITEM="32" ITEM_CATEGORY="41-50 HP" ITEM_NAME="0095PY02(0095PY02)" _29-Aug-2011="1" _05-Sep-2011="3" _12-Sep-2011="4" _19-Sep-2011="4" ></ITEM>
      <ITEM  HIDE_M_SYS_CD_ITEM="32" ITEM_CATEGORY="41-50 HP" ITEM_NAME="0095PY02(0095PY02)" _29-Aug-2011="1" _05-Sep-2011="3" _12-Sep-2011="4" _19-Sep-2011="4" ></ITEM>
      <ITEM  HIDE_M_SYS_CD_ITEM="73" ITEM_CATEGORY=">50 HP" ITEM_NAME="0251PY25(0251PY25)" _05-Sep-2011="2" _12-Sep-2011="1" ></ITEM>
      <ITEM  HIDE_M_SYS_CD_ITEM="73" ITEM_CATEGORY=">50 HP" ITEM_NAME="0251PY25(0251PY25)" _05-Sep-2011="2" _12-Sep-2011="1" ></ITEM>
      <ITEM  HIDE_M_SYS_CD_ITEM="32" ITEM_CATEGORY="41-50 HP" ITEM_NAME="0095PY02(0095PY02)" _29-Aug-2011="1" _05-Sep-2011="3" _12-Sep-2011="4" _19-Sep-2011="4" ></ITEM>
      <ITEM  HIDE_M_SYS_CD_ITEM="32" ITEM_CATEGORY="41-50 HP" ITEM_NAME="0095PY02(0095PY02)" _29-Aug-2011="1" _05-Sep-2011="3" _12-Sep-2011="4" _19-Sep-2011="4" ></ITEM>
      <ITEM  HIDE_M_SYS_CD_ITEM="70" ITEM_CATEGORY=">50 HP" ITEM_NAME="0252PY01(0252PY01)" _29-Aug-2011="2" _19-Sep-2011="2" ></ITEM>
    </ROOT>

    for grid view binding i used this code:-
          var Procurments = (from obj_PIS in xmlContent.Descendants("ITEM")
                                           select obj_PIS).ToList();
                        objProcurementPlan.rdGridViewProcurements.ItemsSource = Procurments;


    in above xDocument attribute in item node change according to my parameter.
    but its not working i didn't get expected result. So how can i use this xml document as itemsource in grid view. 

  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 07 Oct 2011 Link to this post

    Hi,

    You can parse your XML data and create a collection of dynamic objects. For more info about dynamic binding support I suggest you to check this blog post:
    http://blogs.telerik.com/vladimirenchev/posts/11-09-28/dynamic-binding-for-your-silverlight-applications.aspx

    Best wishes,
    Vlad
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top