Wednesday, December 10, 2008

Event code: 3004 File Upload too large

I have a custom application i've been working on and i was trying to upload a 5MB file with an asp fileupload control. This was giving me the dreaded "Internet Explorer Cannot Display the web page." error. I soon realized that the file size was the issue and added an httpruntime element to my web config file.

httpRuntime maxRequestLength="10240"

Ok, so i should be able to upload 10 meg files now. No luck. No matter how i configured the httpruntime element i kept getting the same error. IIS couldn't have been the issue because i was running the app from Visual Studio. I had been stumped for hours when i accidently figured out the issue.

We had several settings in our system.web section of the web config. I put the httpruntime tag at the end of the section. For some reason the application was not seeing it here. When i moved it directly after the tag, the file upload worked fine. I have no idea was causing the tag to work incorrectly or why the location mattered. Any thoughts feel free to share.

Frustrating. Thanks Microsoft.

Thursday, September 25, 2008

gridItem.OwnerTableView.DataKeyValues NullReferenceException

GridDataItem gridItem = e.Item as GridDataItem;
gridItem["ColumnName"].ToolTip = "CustomerID: " + gridItem.OwnerTableView.DataKeyValues[gridItem.ItemIndex][ "ColumnName2"].ToString();

While trying to assign a tooltip to a Telerik Radgrid cell with the above code (courtesy of the Telerik documentation) I kept getting a NullReferenceException. For some reason i could not ascertain the gridItem.ItemIndex kept coming up 0. I circumvented the problem by casting the GridDataItem to a DataRowView and using the named index of the row to get the value. Not sure why Telerik tried to make it so complicated...

GridDataItem gridItem = e.Item as GridDataItem;
DataRowView row = (DataRowView)gridItem.DataItem;
gridItem["ColumnName"].ToolTip = row["ColumnName2"].ToString();