Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

display specific data from read from xml file on asp.net page

Status
Not open for further replies.

ITking2009

Programmer
Aug 4, 2009
23
US
Hi,
What i need to do is display a specific section of the xml file on the webpage.
Here's what i am doing
i am reading the xml file into a dataset and then check for row count and if its more than one i am tying to the table.
the issue i am having is it showing correct count but when i try to display it shows "System.Data.DataRowView" in place of the value to be shown.
Following is my xml and i am having issue showing Payment Requirement section for account id 9999

<FaxForm>
<FaxFormAccountId>9999</FaxFormAccountId>
<FaxFormName>Test</FaxFormName>
<Phone>1-888-888-8888</Phone>
<Fax>1-888-999-9999</Fax>
<CaptionParagraph>
<CaptionContent>TEST1</CaptionContent>
<CaptionContent>Test2</CaptionContent>
<CaptionContent>Test3</CaptionContent>
<CaptionContent>Test4</CaptionContent>
</CaptionParagraph>
<PaymentParagraph>
<PaymentRequirement>TESTING</PaymentRequirement>
<PaymentRequirement>TESTING</PaymentRequirement>
<PaymentRequirement>TESTING</PaymentRequirement>
<PaymentRequirement>TESTING</PaymentRequirement>
<PaymentRequirement>TESTING</PaymentRequirement>
<PaymentRequirement>TESTING</PaymentRequirement>
</PaymentParagraph>
<FaxFormAccountId>8888</FaxFormAccountId>
<FaxFormName>Test</FaxFormName>
<Phone>1-888-888-8888</Phone>
<Fax>1-888-999-9999</Fax>
<CaptionParagraph>
<CaptionContent>TEST1</CaptionContent>
<CaptionContent>Test2</CaptionContent>
<CaptionContent>Test3</CaptionContent>
<CaptionContent>Test4</CaptionContent>
</CaptionParagraph>
<PaymentParagraph>
<PaymentRequirement>TESTING</PaymentRequirement>
<PaymentRequirement>TESTING</PaymentRequirement>
<PaymentRequirement>TESTING</PaymentRequirement>
<PaymentRequirement>TESTING</PaymentRequirement>
<PaymentRequirement>TESTING</PaymentRequirement>
<PaymentRequirement>TESTING</PaymentRequirement>
</PaymentParagraph>
<FaxFormAccountId>7777</FaxFormAccountId>
<FaxFormName>Test</FaxFormName>
<Phone>1-888-888-8888</Phone>
<Fax>1-888-999-9999</Fax>
<CaptionParagraph>
<CaptionContent>TEST1</CaptionContent>
<CaptionContent>Test2</CaptionContent>
<CaptionContent>Test3</CaptionContent>
<CaptionContent>Test4</CaptionContent>
</CaptionParagraph>
<PaymentParagraph>
<PaymentRequirement>TESTING</PaymentRequirement>
<PaymentRequirement>TESTING</PaymentRequirement>
<PaymentRequirement>TESTING</PaymentRequirement>
<PaymentRequirement>TESTING</PaymentRequirement>
<PaymentRequirement>TESTING</PaymentRequirement>
<PaymentRequirement>TESTING</PaymentRequirement>
</PaymentParagraph>
</FaxForm>


here's my code to do that

string dataPath = Server.MapPath("~/App_Data/RFS.xml");
DataSet dSet = new DataSet();
dSet.ReadXml(dataPath);
DataRow[] rows = dSet.Tables[0].Select(" FaxFormAccountId = '" + ConfigurationManager.AppSettings["AccountId"]+"'");
// record validated
if (rows.Length > 0)
{
if (dSet.Tables["PaymentRequirement"].Rows.Count > 0)
{
BulletedList1.DataSource = dSet.Tables["PaymentRequirement"];
BulletedList1.DataBind();

}
}

any suggestions are appreciated.
Thanks.
 
I found a way to do if someone knows a better way let me know.

i am doing following and its working

string dataPath = Server.MapPath("~/App_Data/RFS.xml");
DataSet dSet = new DataSet();
dSet.ReadXml(dataPath);
DataRow[] rows = dSet.Tables[0].Select(" FaxFormAccountId = '" + ConfigurationManager.AppSettings["AccountId"]+"'");
// record validated
if (rows.Length > 0)
{
if (dSet.Tables["PaymentRequirement"].Rows.Count > 0)
{
foreach (DataRow row in dSet.Tables["PaymentRequirement"].Rows)
{ BulletedList1.Items.Add(row[0].ToString ()); }
//BulletedList1.DataSource = dSet.Tables["PaymentRequirement"].Rows ;
//BulletedList1.DataBind();
}
}

Thanks.
 
are you sure the xml is properly populating the dataset? if the xml is hierarchical I don't think it will load into a dataset as relational tables. this would be the first problem.

2nd. what does the aspx markup look like/ this is where the DataRowView issue is happening. it throws at DataBind because this is the last debuggable point in your code.

I would approach this differently. load the xml into an xml reader or xml document and use an xpath query to navidate to the correct node. prase these values yourself and load into the markup.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
faq732-7259
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top