Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

c# asp.net databind() xml to gridview

Posted on 2010-08-23
4
Medium Priority
?
490 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

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

926 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