SqlDataSource erroring when retrieving NVARCHAR(max) column
I'm writing a small ASP .Net application in order to retrieve data from a SQL database. The application uses drop downs in order to select what the next drop down should contain and when a page is selected, it should retrieve the HTML from the database. Everything is working until it gets to the retrival of the HTML data. When I try to retrieve the data, I get:
Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: 开发者_StackOverflowAn unknown error occurred while processing the request on the server. The status code returned from the server was: 500
The HTML column is a defined as NVARCHAR(MAX)
, but I can't see this causing a problem. The application works if I set the DataValueField
to another column. Has one else come across a problem like this? Maybe someone could shine some light on this?
One thing I noted when dealing with varchar(max) columns is that the framework still commonly expects to have a size associated with it. What I ended up having to do was specify the length as -1 to get it to accept a varchar(max) field. Your error message doesn't indicate that this is the problem, but you might try experimenting with it rather than turning off the validation, which could possibly have other repercussions.
Figured it out. Just needed to set ValidateRequest
to false
at the Page
level.
精彩评论