Attention: We are retiring the ASP.NET Community Blogs. Learn more >

DataBinding and ReadOnly attributes

It seems most our our woes with DataBinding and updates\inserts have been related to ReadOnly elements in our schema.

I saw this during Update testing and just now saw it during Insert testing. In one case, our sproc returns a calculated field that stores T or F (true or false):

MailStopEnabled =

CASE WHEN n.faddr = '######' THEN 'false'

ELSE 'true'

END

<xs:element name="MailStopEnabled" msdata:ReadOnly="true" minOccurs="0">

We databind one of our textbox control's enabled property to this. Well, it seems calling AddNew fails when we do this.

The new row is created, however you can never set the Position to that new row. As soon as I remove the binding to the calculated field, calls to AddNew work. By work I mean all of the controls are cleared out, a new row is created and the client is positioned to that new row.

My question is, if I want the proc to continue to build this field and we want to continue to bind to it, are there anyways to:

1- turn off the ReadOnly on this element

2- somehow work around this

We do not need to update or do an insert on this field. In fact, the field does not even exist in our database. We were simply trying to come up with a slick way to disabled this textbox when a certain condition is met the the sql query.

So, what I think I am seeing is inserts and updates for databinding will not work if you are using calculated fields from sql server or otherwise setting a ReadOnly attribute on your element in the schema.

2 Comments

  • Greg,



    How are you generating your schemas?

  • We are using the default schema generated by the call to Fill, with MissingSchemaAction = MissingSchemaAction.AddWithKey. Given the size of the SQL Table we are working with, generating the schema by hand would be a maintenance nightmare.

Comments have been disabled for this content.