I spent most of yesterday trying to figure this perplexing issue out that should be quite simple (SHOULD being the operative word).
I have a table that I'm generating in the code behind from a datatable. The table contains a bunch of checkboxes with the names of employees next to the them. The name of the employee is a linkbutton that navigates to another page (this works fine). I would've used a checkboxlist except I wasn't able to make the names links using that ... but anyway I digress ...
The problem is the checkboxes. I want certain checkboxes to be checked and others not according to information provided in the datatable. I figured that I would just used the .Checked property ... right?
My checkboxes have the id of cbx with the employeeID concatenated onto it (ex. cbx211, cbx987, etc). If I reference the checkbox this way it works:
ck = (CheckBox) FindControl ("cbx196"
ck.Checked = true;
If it reference it through the datatable it does not:
ck = (CheckBox) FindControl ("cbx" + projResData.Rows [0]["RESOURCE_ID"].ToString ());
ck.Checked = true;
When I step through the code projResData.Rows [0]["RESOURCE_ID"] comes out to be 196 so the id is correct as cbx196 but it will not check!!! Yet if I hard-code it ... IT WORKS!!!
Crazy! Yes! Or maybe I'm losing my mind. I have been scratching my head trying to figure this out for several hours now and have not been able to find much help on the web. Has anyone run into this before? If so ... PLEASE HELP!!!!
Desperately,
VBRookie
PS
Don't let the name fool you ... I'm coding this in C#.
I have a table that I'm generating in the code behind from a datatable. The table contains a bunch of checkboxes with the names of employees next to the them. The name of the employee is a linkbutton that navigates to another page (this works fine). I would've used a checkboxlist except I wasn't able to make the names links using that ... but anyway I digress ...
The problem is the checkboxes. I want certain checkboxes to be checked and others not according to information provided in the datatable. I figured that I would just used the .Checked property ... right?
My checkboxes have the id of cbx with the employeeID concatenated onto it (ex. cbx211, cbx987, etc). If I reference the checkbox this way it works:
ck = (CheckBox) FindControl ("cbx196"
ck.Checked = true;
If it reference it through the datatable it does not:
ck = (CheckBox) FindControl ("cbx" + projResData.Rows [0]["RESOURCE_ID"].ToString ());
ck.Checked = true;
When I step through the code projResData.Rows [0]["RESOURCE_ID"] comes out to be 196 so the id is correct as cbx196 but it will not check!!! Yet if I hard-code it ... IT WORKS!!!
Crazy! Yes! Or maybe I'm losing my mind. I have been scratching my head trying to figure this out for several hours now and have not been able to find much help on the web. Has anyone run into this before? If so ... PLEASE HELP!!!!
Desperately,
VBRookie
PS
Don't let the name fool you ... I'm coding this in C#.