Tuesday, March 2, 2010

Find distinct values from a datatable / dataset

To filter the datatable based on the distinct value of a column, use the below code
dataSet.Tables(0).DefaultView.ToTable(true,"ColumnName") ;
or  dataTable.DefaultView.ToTable(true,"ColumnName") ;
where ColumnName is the name of the column whose distinct value is to be found.

Saturday, February 13, 2010

Accept Button in WPF

How do we achieve the accept button and cancel button in WPF?
We just have to set the button attributes for enable those features.
      Accept Button - Button.IsDefault = "True"
      Cancel Button -  Button.IsCancel = "True"

Wednesday, October 14, 2009

Show hidden files option not getting retained

Why is "Show hidden files" option  not getting retained?
This is because, the update is not getting saved in registry because of the effect of virus. This can be fixed easily by following the steps below.


  1. Type regedit in Run command
  2. Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Folder\Hidden\SHOWALL
  3. Delete the entry CheckedValue in the right pane by right clicking on the entry and click delete.
  4. Create a new DWORD value entry by right clicking and clicking New-> DWORD value
  5. Change the name of new dword to CheckedValue
  6. Right click on the CheckedValue entry, hit modify and change value to 1. Hit OK.
  7. Thats all. The problem is solved.

Double click not working on drives.

This problem is because of the effect of virus which is very easy to fix. A file named autorun.inf might be created in the root directory of each drives. Deleting those files will fix the problem. Follow the steps below.

  1. Type cmd in Run window.
  2. If the drive is not C, type C: in command prompt
  3. Type cd\ to move to the root directory
  4. Type "attrib -r -h -s autorun.inf"
  5. Type "del autorun.inf"
  6. Move to next drive by typing D:
  7. Repeat the above steps(4 to 6) for all the drives.
  8. Restart the system.

Saturday, October 10, 2009

The changed values of a read only or disabled text box is not retained after postback

ScenarioThe changed values of a read only or disabled text box is not retained after postback.
Reason : Browser is not maintaining the state of a read only or disabled control.
Solution: The values of all the form controls are maintained inside Request.Form. So include the following code snippet inside page load to retain the values dynamically in the textbox.
Inside Page_Load
if(IsPostBack)
TextBox1.Text = Request.Form(this.TextBox1.ClientID);

Removing Yahoo Messenger from StartUp

For removing any item from start up, the normal practice is to remove the item from startup option in msconfig. For that do the following steps.


  1. Type msconfig in run command. (Admin privilege is required)
  2. In the configuration window that is popped up, select the startup tab.
  3. Uncheck the applications you want to remove from start up.
  4. Click Ok.
  5. From the next reboot onwards, the application wont start on startup.
For removing yahoo messenger, the above approach alone wont work. Do this extra stuff for accomplishing that.


  1. Login to Yahoo Messenger.
  2. Select  Messenger Menu Item. 
  3. Select Preferences.
  4. Select General Category.
  5. Uncheck automatically start yahoo messenger option. 
  6. Click OK.





Yahoo Messenger Preferences


If both these approaches are not working, follow the third and final approach. This is by removing the entry from registry as explained below.

  1. Stop yahoo if already running. Thia can be done by right click yahoo icon in taskbar and click exit.
  2. Take registry editor. This can be done by typing regedit in Run command.
  3. Navigate to the node "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
  4. Delete the entry Yahoo! Pager. (It is advisable to keep a back up of the registry entry before making any changes. This can be done by right clicking on Run Node and select export)
  5. Restart system.

Thursday, October 8, 2009

Clearing an ajax combobox in ASP.Net

An ajax combo-box  coming with 3.5 framework is not working the expected way when it comes in rebinding the combo-box and clearing the selection value. The normal combo-box.ClearSelection() wont work in this case. It is because the combo-box selection value is saved inside a hidden control which is not getting cleared. The above problem can be solved by including the following code snippet.


           combobox1.ClearSelection();
            foreach (Control control in combobox1.Controls)
            {
                if (control is HiddenField)
                    ((HiddenField)control).Value = "0"; //Where 0 is the value associated with the first selection item.
            }