Tuesday, October 19, 2010

Unable to cast object of type System.Data.DataRowView to type System.IConvertible

Wow...

Long time.. A lot of distractions. I have been interested in a lot new things. With Windows Phone, Robotics coming into picture, the hobbies and pass-times all changed around.

But to get back on the track.. Here is a very small piece of information that I am sure would help a lot of people.

I encountered the above error while working with a Combobox in a Windows Application.

This would come up every time the form loads and the the SelectedValue of the combobox was selected.

This normally would occur to comboboxes, which are databound.

So here is the problem and the solution.

This is how we usually bind the combobox to data

cboBox.DataSource = data_set.Tables["table_name"].DefaultView;

cboBox.DisplayMember = "field_name";

cboBox.ValueMember = "field_id";


Instead, to resolve this issue all we need to do is first specify the DisplayMember and ValueMember and then Bind.


cboBox.DisplayMember = "field_name";

cboBox.ValueMember = "field_id";

cboBox.DataSource = data_set.Tables["table_name"].DefaultView;


Tuesday, April 6, 2010

App_Offline.htm

Phheeewwwww,

Back after a looong time. Its all been busy so long and was not able to post here something for long.
Now.... I have something to post + I have the time. So here we go....
Learnt a new concept today - App_Offline.htm.

There is a simple way to bring down your ASP.NET 2.0 application. The only thing you have to do is to create simple html file called App_offline.htm and deploy it to your ASP.NET 2.0 web application root directory. The rest is handled by ASP.NET runtime internal routines

This approach is extremely helpful for scenarios where we need to bring down the application instantly for some quick updates or any other purpose.

It stops processing new incomming requests and serves the contents of this App_offline.htm file.

Since the whole application domain is unloaded, all application files and assemblies are unlocked and we can make any necessary changes. When done with the changes, all we need to do is rename or delete App_offline.htm file and the next incoming request will bring the ASP.NET 2.0 web application back online.

There is also one great use of this. In order to unlock any attached Database files. This way, they are released and unlocked to be copied over anywhere.


Hope this helps someone, somehow.