This is a migrated thread and some comments may be shown as answers.

Bind xml data as item source in GridView

1 Answer 56 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ramkrishn
Top achievements
Rank 1
Ramkrishn asked on 07 Oct 2011, 02:52 PM
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. 

1 Answer, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 07 Oct 2011, 02:54 PM
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 >>

Tags
GridView
Asked by
Ramkrishn
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Share this question
or