Click here to Skip to main content
15,909,091 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
am creating a class to check the items on the checklistbox base on the data in the db.
but am getting the error 'the name "ChechState" does not exist in the current context'
please help me out

public void getMinistry(ref System.Windows.Forms.CheckedListBox cr, string strID)
{
SqlConnection conn = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
conn.ConnectionString = "Data Source=USER-PC;Initial Catalog=PIWCDB;User ID=sa;Password=mike";
conn.Open();

SqlCommand cmd = new SqlCommand();
string sqlQuery = null;
sqlQuery = "SELECT Ministryname FROM tblMembershipministry WHERE FormattedMembershipid ='" + strID + "'";

cmd.Connection = conn;
cmd.CommandText = sqlQuery;
cmd.CommandType = System.Data.CommandType.Text;

System.Data.SqlClient.SqlDataReader dr = null;
dr = cmd.ExecuteReader();

while (dr.Read())
{
cr.SetItemCheckState(cr.Items.IndexOf(dr["Ministryname"]), CheckState.Checked);
}

cmd.Dispose();
}
Posted
Comments
[no name] 13-May-14 12:58pm    
Try changing to System.Windows.Forms.CheckState

1 solution

Hi,

I think your problem is that you have not imported the namespaces you need in order to use CheckState. You've defined this method in another cs file. Try to import the required assembly (I do not remember which assembly, I'm looking for it and I'll post it asap, but try to import System.Windows.Forms)

Bye!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900