Solved

c# asp.net databind() xml to gridview

Posted on 2010-08-23
4
430 Views
Last Modified: 2013-11-07
i have the below code. it is returning xml data back from the stored poc in the form:
<row ProjectMilestoneId="2" ProjectId="2" MilestoneCID="1" MilestoneText="High" StartDate="1933-05-16T00:00:00" EndDate="2033-01-01T00:00:00" RAGStatusCID="7" RAGStatusText="Red                                               " CompletionStatusCID="33" CompletionStatusText="Delayed                                           " StatusText="testing text11111" Added="2010-08-23T15:06:52.580" LastUpdate="2010-08-23T15:06:52.580" UpdateBy="mshinder" />
<row ProjectMilestoneId="3" ProjectId="2" MilestoneCID="1" MilestoneText="High" StartDate="1933-05-16T00:00:00" EndDate="2033-01-01T00:00:00" RAGStatusCID="7" RAGStatusText="Red                                               " CompletionStatusCID="33" CompletionStatusText="Delayed                                           " StatusText="testing text11111" Added="2010-08-23T15:06:54.707" LastUpdate="2010-08-23T15:06:54.707" UpdateBy="mshinder" />
<row ProjectMilestoneId="4" ProjectId="2" MilestoneCID="1" MilestoneText="High" StartDate="1933-05-16T00:00:00" EndDate="2033-01-01T00:00:00" RAGStatusCID="7" RAGStatusText="Red                                               " CompletionStatusCID="33" CompletionStatusText="Delayed                                           " StatusText="testing text11111" Added="2010-08-23T15:06:54.910" LastUpdate="2010-08-23T15:06:54.910" UpdateBy="mshinder" />
<row ProjectMilestoneId="5" ProjectId="2" MilestoneCID="1" MilestoneText="High" StartDate="1933-05-16T00:00:00" EndDate="2033-01-01T00:00:00" RAGStatusCID="7" RAGStatusText="Red                                               " CompletionStatusCID="33" CompletionStatusText="Delayed                                           " StatusText="testing text11111" Added="2010-08-23T15:06:55.127" LastUpdate="2010-08-23T15:06:55.127" UpdateBy="mshinder" />
XmlReader xr = cmd.ExecuteXmlReader();

DataSet ds2 = new DataSet();

ds2.ReadXml(xr, XmlReadMode.InferSchema);

if (xr != null) xr.Close();

            

DataView myDataView = ds2.Tables[0].DefaultView;



if (sortExp != string.Empty)

                myDataView.Sort = string.Format("{0} {1}", sortExp, sortDir);



gvMilestone.DataSource = myDataView;

gvMilestone.DataBind();

Open in new window

0
Comment
Question by:realcoding
  • 2
4 Comments
 
LVL 35

Expert Comment

by:YZlat
ID: 33504509
what is the issue with your code?
0
 
LVL 10

Expert Comment

by:Jini Jose
ID: 33504606
0
 

Author Comment

by:realcoding
ID: 33504667
gmailjini: sorry way off base.

my code has an index out of range exception in the line:
DataView myDataView = ds2.Tables[0].DefaultView;

0
 

Accepted Solution

by:
realcoding earned 0 total points
ID: 33561864
the xml should be in format of for xml raw not for xml auto. this does the trick.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
ASP.NET e-commerce website 4 30
Problem to open Excel file 15 44
cs.Designer Issue 2 19
Calling stored proc in EDMX 11 19
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now