Solved

c# asp.net databind() xml to gridview

Posted on 2010-08-23
4
460 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

752 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