XML Dateset 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.
 
W

William F. Robertson, Jr.

It has nothing to do with your XML stuff.

I am guessing the "getcontroltype" variable is null. Or atleast all your
xml code works and if I change it from getcontroltype to the string "hello"
it works properly.

bill
 
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

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,276
Latest member
Sawatmakal

Latest Threads

Top