JG Vimalan's Blog

It is all about coding!

Cannot bind to the new display member. Parameter name: newDisplayMember

I got this error when I was trying to bind datasource in a combobox and set values in the ‘DisplayMember’ and ‘ValueMember’.

Here is the code snippet,

public class ClinicInfo
internal string ClinicID { get; set; }
internal string ClinicName { get; set; }

public override string ToString()
return ClinicName;

//Code for binding the data into ComboBox

IEnumerable<ClinicInfo> clinics = DBGateway.GetActiveClinics();

ClinicCmbBox.DataSource = clinics;
ClinicCmbBox.ValueMember = “ClinicID”;
ClinicCmbBox.DisplayMember = “ClinicName”;

Everything was looking good except the Access Modifiers (internal) for the properties in ClinicInfo class.

When I changed that to public as shown below, everything worked fine.

public string ClinicID { get; set; }
public string ClinicName { get; set; }

So, the properties you are setting in ‘ValueMember’ and ‘DisplayMember’ should be public.


September 27, 2011 Posted by | C#.NET, Windows Forms | 2 Comments

Binding DirectoryInfo in TreeView

The following code block will give an idea on binding directoryinfo in TreeView control.

protected void Page_Load(object sender, EventArgs e)
if (!IsPostBack)

private void LoadLeftNav()
string root = @”D:\Projects”;
DirectoryInfo rootDirectory = new DirectoryInfo(root);
TreeNode rootNode = new TreeNode(rootDirectory.Name);
rootNode.Value = rootDirectory.FullName;
rootNode.ToolTip = rootDirectory.Name;
LoadProjects(rootNode, rootDirectory);

private void LoadProjects(TreeNode rootNode, DirectoryInfo rootDirectory)
DirectoryInfo[] compaines = rootDirectory.GetDirectories();

foreach (DirectoryInfo company in compaines)
TreeNode node = new TreeNode(company.Name);
node.Value = company.FullName;
node.ToolTip = company.Name;
this.LoadProjects(node, company);

September 26, 2011 Posted by | ASP.NET, C#.NET | Leave a comment

The communication object, System.ServiceModel.ChannelFactory…, cannot be used for communication because it is in the Faulted state.

I got the error message (The communication object, System.ServiceModel.ChannelFactory…, cannot be used for communication because it is in the Faulted state.) in the production system, which was working fine for months. I found that, the WCF service is up and running and it is able to connect to database and is connected to the application as well. So, to fix this issue I followed the steps given below.

a. Stop the application pool of the application which is consuming the WCF service.

b. Browse to the C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files

c. Delete the temp folder of the application which is using the WCF service. (The reason is, even though you restart IIS, the corrupted files will be here and it will cause the issue)

e. Start the application pool.

That’s it! This resolved my issue and the application started to work normally. Although, I am not clear on what exactly happened to cause this issue, I found the solution.

September 8, 2011 Posted by | ASP.NET, WCF | 1 Comment

Setting css class with javascript

In this post, I am going to explain about setting css class for controls using javascript.

The following javascript will give you an idea of setting css class to a control for IE and other browsers.


var anchl = document.getElementById(‘largeFontSwitch’); //Id of the control

//Remove class
anchl.setAttribute(“class”, “”); //Other browsers
anchl.className = “”; //IE

//Set class

anchl.setAttribute(“class”, “selectedFont”); //Other browsers
anchl.className = “selectedFont”; //IE

September 6, 2011 Posted by | JavaScript | Leave a comment