?
Solved

DataList help

Posted on 2004-08-18
3
Medium Priority
?
284 Views
Last Modified: 2010-04-15
Hi,

I have a DataList control to which I am binding a DataSet generated from an XML File.

The file structure is usually fixed, however, on occasion some Elements get missed from the document.

When I do the databinding, I (obviously) get the following error:
DataBinder.Eval: 'System.Data.DataRowView' does not contain a property with the name Quantity


The line of code in the template causing the problem being:
<asp:label id=Label15 runat="server" font-size="10" Text='<%# DataBinder.Eval(Container, "DataItem.Quantity") %>'></asp:label>


What I'd like to know is:
a) Can I make some of the databound items optional, so if they are not present in the dataset they simply dont get bound?
b) Is there any other work around for this?

Theres a lot of fields in this document (30+) so I'd really rather not have to check for them individually if possible.


Cheers,
Stew
0
Comment
Question by:stewfidgeon
[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
3 Comments
 
LVL 3

Accepted Solution

by:
nhewitt21 earned 1000 total points
ID: 11829841
The only thing i can think of to do this would be to loop through your dataset before you bind it, check if the 'Quantity' exists, if it does np, if it doesn't add it but just make it a null field.

hope this helps


0
 
LVL 1

Author Comment

by:stewfidgeon
ID: 11830089
nHewitt21


Thanks for that mate. I appreciate the help.

What I've done as a work around is pretty similar. Ive created a string with all possible column names in it (theres about 40 possibilities), and split that into an array.

I check each string value in the array to see if the column exists. If it does, I dont do anything, if it doesnt, then I create a column of the same name, set the default value to "N/A", and add the column.


In the absence of any answers letting me optionally bind columns if the data exists, I'll accept your answer by the end of the day.
0
 
LVL 3

Expert Comment

by:nhewitt21
ID: 11830200
Thanks i understand, its a hard one this.
i have been looking for ways to optionally bind columns for a while but i've not found anything at all, yet.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month11 days, 3 hours left to enroll

770 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