kescott
Posts: 49
|
Posted: 11/20/2008, 2:10 PM |
|
I'm trying to display the checkbox value from another database table to Grid:Vendors by using this code:
//Get Control
System.Web.UI.WebControls.CheckBox VendorsCheckBox1 =
(System.Web.UI.WebControls.CheckBox)
(e.Item.FindControl("VendorsCheckBox1"));
//Retireve value from other database table
VendorsCheckBox1.Checked = (new CheckBox
("",Settings.identification_DEVELOPMENTDataAccessObject
.ExecuteScalar("SELECT <booleanColumn> FROM <differentTable>"))).Checked("");
Got an ideas?
_________________
B.S. of Computer Science
Class of 2005
Norfolk State University
Norfolk, VA
http://www.nsu.edu
|
|
|
kescott
Posts: 49
|
Posted: 11/24/2008, 8:35 AM |
|
I believe I solved this issue with the following code:
First of all for checkbox I set Data Type to Boolean
(I assume that custom sql returns a value of boolean type field).
And you need to create not a new "Checkbox" but new "BooleanField" instance:
VendorsCheckBox1.Checked = (new BooleanField...
Then apply ParseBool method of DBUtility to convert String value returned by the code to Boolean value:
VendorsCheckBox1.Checked =DBUtility.ParseBool((new BooleanField... ,"")
So in common the should looks like:
<form_name><checkbox_name>.Checked = DBUtility.ParseBool
((new BooleanField("",Settings.DatabaseConnectionName>
DataAccessObject.ExecuteScalar
("Custom SQL"))).GetFormattedValue(""),"");
Anyone know if this is correct?
_________________
B.S. of Computer Science
Class of 2005
Norfolk State University
Norfolk, VA
http://www.nsu.edu
|
|
|
|