XML & Datset problem

  • Thread starter Thread starter Chris Kennedy
  • Start date Start date
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.
 
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
 
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.
 
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
 
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.
 
Back
Top