Solved

c# asp.net databind() xml to gridview

Posted on 2010-08-23
4
433 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

912 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

24 Experts available now in Live!

Get 1:1 Help Now