XML & Datset problem

C

Chris Kennedy

I am having big problem manipulating XML in a dataset. I am reading in a
schema based on the following XML document. The minute I try to e.g. create
a new row I get 'Object reference not set to an instance of an object' error

<?xml version="1.0" encoding="utf-8"?>
<DocumentElement xmlns="http://tempuri.org/dseditted2.xsd">
<TableInfo>
<FieldName>column value</FieldName>
<ControlType>column value</ControlType>
<IsNull>column value</IsNull>
<MaxLength>column value</MaxLength>
</TableInfo>
</DocumentElement>

editteddataset = New DataSet()
editteddataset.ReadXmlSchema("C:\Inetpub\wwwroot\xmlxconfig\dseditted2.xsd")
Dim dsItem As DataRow
Dim dsTable As DataTable
dsTable = editteddataset.Tables("TABLEINFO")
dsItem = editteddataset.Tables("TABLEINFO").NewRow
Dim getcontroltype As DropDownList
getcontroltype = CType(e.Item.FindControl("controltype"), DropDownList)
THIS IS THE LINE OF CODE WHICH GENERATES THE ERROR
dsItem("CONTROLTYPE") = getcontroltype.DataTextField
What am I not understanding about XML, As I am fine when it is pulled from a
database.
 
G

Guest

Hi, Chris

Have you debugged through the code to find out which object lost reference
I would check whether getcontroltype is nothing or not after this line
getcontroltype = CType(e.Item.FindControl("controltype"), DropDownList

Bin Song, MCP
 
C

Chris Kennedy

The debugger doesn't work. I have reinstalled it several times and it works
for a while and then I get an error saying the debugger isn't working. Sorry
I can't remember the specific error. I know it is slightly OT but has anyone
experienced this. By the way I am using VB.NET standard on W2K.
 
G

Guest

Can you try the following
Dim ctl as Contro
ctl = e.Item.FindControl("controltype"
If Not ctl Is Nothing Then
Dim getcontroltype As DropDownLis
getcontroltype = CType(ctl, DropDownList
dsItem("CONTROLTYPE") = getcontroltype.DataTextFiel
End If
 
C

Chris Kennedy

You and another person pointed me in the right direction. I'd simply
misnamed something in the HTML template for the datagrid. I'm new to .net
and you know when you're new to something you don't have that instinct when
you know it will be something really really obvious. Starring at the code
for ages doesn't help. Thanks for the help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top