Checkbox values in Repeater Control
-
I'm trying to set the Checked value in a checkbox inside a repeater control. The code I am using for this is I am getting a 'Specified cast is not valid.' error when I run this. When filling the 'Active' Column in the dataset I have tried both using a string "True" and a boolean true to attempt to set the value. I get the same error both ways. Everything I can find online shows that this is the right method to do this, but I am unable to resolve this error. Any pointers on this would be very appreciated. The wisest of the wise may err. - Aeschylus -- modified at 3:33 Sunday 13th November, 2005
-
I'm trying to set the Checked value in a checkbox inside a repeater control. The code I am using for this is I am getting a 'Specified cast is not valid.' error when I run this. When filling the 'Active' Column in the dataset I have tried both using a string "True" and a boolean true to attempt to set the value. I get the same error both ways. Everything I can find online shows that this is the right method to do this, but I am unable to resolve this error. Any pointers on this would be very appreciated. The wisest of the wise may err. - Aeschylus -- modified at 3:33 Sunday 13th November, 2005
Baatezu wrote:
DataBinder.Eval(Container, "DataItem.Active")
I would change this to use ? : notation to return the string true or false, based on the result of DataBinder.Eval. Christian Graus - Microsoft MVP - C++
-
Baatezu wrote:
DataBinder.Eval(Container, "DataItem.Active")
I would change this to use ? : notation to return the string true or false, based on the result of DataBinder.Eval. Christian Graus - Microsoft MVP - C++
Yep, that's actually the problem... when the code snippet is executed, what happens is that it tries to write a string out of a boolean without a proper type cast. so you can either make: DataBinder.Eval(Container, "DataItem.Active").ToString(); or what Christian says: (DataBinder.Eval(Container, "DataItem.Active") ? "True" : "False") daniero