473,386 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

DataBind Problem

I have a drop down list, which binds to dataset based on an XML file like the one below.

<xmlform>
<formelement id="0">
<maxlength>234</maxlength>
<datatype>String</datatype>
<isnull>true</isnull>
<index>0</index>
</formelement>
</xmlform>

Sometime the XML will have nothing in it like so

<xmlform>
</xmlform>

The databind routine can't find any columns and hence throws an error. Is there a straight forward way to test for this an then not bind?
Nov 19 '05 #1
7 1047
JV
You could preload it using XmlDocument and see if it has the nodes you are
expecting.

"Chris Kennedy" <ck**************@bleyonder.co.uk> I have a drop down list,
which binds to dataset based on an XML file like the one below.
The databind routine can't find any columns and hence throws an error. Is
there a straight forward way to test for this an then not bind?
Nov 19 '05 #2
Could you give us a pointer in code as I am al ittle new to XML. Would a
node list in Xpath do the job?

"JV" <jo**********@goisc.com> wrote in message
news:u8*************@TK2MSFTNGP15.phx.gbl...
You could preload it using XmlDocument and see if it has the nodes you are
expecting.

"Chris Kennedy" <ck**************@bleyonder.co.uk> I have a drop down list, which binds to dataset based on an XML file like the one below.
The databind routine can't find any columns and hence throws an error. Is
there a straight forward way to test for this an then not bind?

Nov 19 '05 #3
On Fri, 01 Jul 2005 10:13:40 -0700, Chris Kennedy wrote:
Could you give us a pointer in code as I am al ittle new to XML. Would a
node list in Xpath do the job?

"JV" <jo**********@goisc.com> wrote in message
news:u8*************@TK2MSFTNGP15.phx.gbl...
You could preload it using XmlDocument and see if it has the nodes you are
expecting.

"Chris Kennedy" <ck**************@bleyonder.co.uk> I have a drop down

list,
which binds to dataset based on an XML file like the one below.
The databind routine can't find any columns and hence throws an error. Is
there a straight forward way to test for this an then not bind?

My approach - you say that you already have a DataSet from the XML (via
ReadXML() method). Look in the properties of the DataSet (for example
Tables gives you the tables collection); from this you can infer whether
dataset is empty and prevent the Bind.

Nov 19 '05 #4
I tried doing a table count but could get it to work.I did this instead, it
works although I am sure you could something with less lines of code.

Function nodecount() As Integer
xmldoc = Session("xmldoc")
Dim intnodecount As Integer = 0
xmllist = xmldoc.GetElementsByTagName("formelement")
For Each xmlnode In xmllist
intnodecount = intnodecount + 1
Next
If intnodecount = 0 Then
lbltest.Text = "XML Config File is empty"
End If
Return intnodecount
End Function

"intrader" <in******@attglobal.net> wrote in message
news:pa****************************@attglobal.net. ..
On Fri, 01 Jul 2005 10:13:40 -0700, Chris Kennedy wrote:
Could you give us a pointer in code as I am al ittle new to XML. Would a
node list in Xpath do the job?

"JV" <jo**********@goisc.com> wrote in message
news:u8*************@TK2MSFTNGP15.phx.gbl...
You could preload it using XmlDocument and see if it has the nodes you are expecting.

"Chris Kennedy" <ck**************@bleyonder.co.uk> I have a drop down

list,
which binds to dataset based on an XML file like the one below.
The databind routine can't find any columns and hence throws an error. Is there a straight forward way to test for this an then not bind?

My approach - you say that you already have a DataSet from the XML (via
ReadXML() method). Look in the properties of the DataSet (for example
Tables gives you the tables collection); from this you can infer whether
dataset is empty and prevent the Bind.

Nov 19 '05 #5
Or, of course, you could use a Try..Except block, and trap the error
that gets thown when the list is empty...

Cheers,
zdrakec

Nov 19 '05 #6
Chris,

please fix your system date.

You're future posting.

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"Chris Kennedy" <ck**************@bleyonder.co.uk> wrote in message
news:Ol**************@TK2MSFTNGP09.phx.gbl...
I tried doing a table count but could get it to work.I did this instead, it
works although I am sure you could something with less lines of code.

Function nodecount() As Integer
xmldoc = Session("xmldoc")
Dim intnodecount As Integer = 0
xmllist = xmldoc.GetElementsByTagName("formelement")
For Each xmlnode In xmllist
intnodecount = intnodecount + 1
Next
If intnodecount = 0 Then
lbltest.Text = "XML Config File is empty"
End If
Return intnodecount
End Function

"intrader" <in******@attglobal.net> wrote in message
news:pa****************************@attglobal.net. ..
On Fri, 01 Jul 2005 10:13:40 -0700, Chris Kennedy wrote:
> Could you give us a pointer in code as I am al ittle new to XML. Would a
> node list in Xpath do the job?
>
> "JV" <jo**********@goisc.com> wrote in message
> news:u8*************@TK2MSFTNGP15.phx.gbl...
>> You could preload it using XmlDocument and see if it has the nodes you are >> expecting.
>>
>> "Chris Kennedy" <ck**************@bleyonder.co.uk> I have a drop down
> list,
>> which binds to dataset based on an XML file like the one below.
>> The databind routine can't find any columns and hence throws an error. Is >> there a straight forward way to test for this an then not bind?
>>
>>

My approach - you say that you already have a DataSet from the XML (via
ReadXML() method). Look in the properties of the DataSet (for example
Tables gives you the tables collection); from this you can infer whether
dataset is empty and prevent the Bind.


Nov 19 '05 #7
On Sat, 02 Jul 2005 07:16:22 -0700, Chris Kennedy wrote:
I tried doing a table count but could get it to work.I did this instead, it
works although I am sure you could something with less lines of code.

Function nodecount() As Integer
xmldoc = Session("xmldoc")
Dim intnodecount As Integer = 0
xmllist = xmldoc.GetElementsByTagName("formelement")
For Each xmlnode In xmllist
intnodecount = intnodecount + 1
Next
If intnodecount = 0 Then
lbltest.Text = "XML Config File is empty"
End If
Return intnodecount
End Function

"intrader" <in******@attglobal.net> wrote in message
news:pa****************************@attglobal.net. ..
On Fri, 01 Jul 2005 10:13:40 -0700, Chris Kennedy wrote:
> Could you give us a pointer in code as I am al ittle new to XML. Would a
> node list in Xpath do the job?
>
> "JV" <jo**********@goisc.com> wrote in message
> news:u8*************@TK2MSFTNGP15.phx.gbl...
>> You could preload it using XmlDocument and see if it has the nodes you are >> expecting.
>>
>> "Chris Kennedy" <ck**************@bleyonder.co.uk> I have a drop down
> list,
>> which binds to dataset based on an XML file like the one below.
>> The databind routine can't find any columns and hence throws an error. Is >> there a straight forward way to test for this an then not bind?
>>
>>

My approach - you say that you already have a DataSet from the XML (via
ReadXML() method). Look in the properties of the DataSet (for example
Tables gives you the tables collection); from this you can infer whether
dataset is empty and prevent the Bind.

That works, but int the future just get Tables.length.

Nov 19 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Stephen | last post by:
Hey everyone. I was wondering if someone could help me with a small problem. I have designed a user control and I would have inserted it on a aspz page (WebForm1). The User control is being used to...
4
by: Stephen | last post by:
Hey everyone. I was wondering if someone could help me with a small problem. I have designed a user control and I would have inserted it on a aspz page (WebForm1). The User control is being used to...
2
by: Andrew | last post by:
Hey all, Have a strange one here, and being still fairly new to .NET isn't helping me understand it. I am having a problem where a DataReader doesn't return all the rows when I try to use a...
7
by: Martin | last post by:
Hi, I have a page where according to the mode of use, different controls are visible. I had assumed that Page.DataBind() would only bind visible controls, but apparently not. Do I have to...
1
by: Tomislav Bartolin | last post by:
Hi, I have an aspx page which contains an ascx user control. I am using Page.DataBind in Page_Load event of the page to bind elements to page properties. The problem is the ascx uses its...
2
by: martyn_wynne | last post by:
Hi, I have found a odd one, my submit button is not submitting on a method="get" form after using any form of DataBind? Has anyone struck this problem before? here is snipits of the code as...
2
by: jslaybaugh | last post by:
I am trying to bind to a GridView or DetailsView after a callback using the ClientCallback Manager in the new .NET 2.0 framework. See below for the HTML followed by the VB code: <html...
1
by: Alex Maghen | last post by:
I have a DataGrid on my ASPX and I'm confused about the interaction with the page based on whether the page is just loading or is being reloaded with a call to the SortCommand of the DataGrid: ...
0
by: nicklang | last post by:
Say you are creating a page which contains a child control which uses a DataList or DataGrid control. In a DataList, the rows are dynamic controls and are data bound, so you have to first load the...
6
by: Jonathan Wood | last post by:
I have a databound dropdownlist control. Based on some other criteria, I need to specify the selected item in my pages Load event. The problem is that, in my load event, the control does not yet...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.