Programmatically using SqlDataSource

G

Guest

hey all,

i have the following statement:

protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{

SqlDataSource1.UpdateParameters["FollowUp"].DefaultValue=((CheckBox)sender).Checked?"1":"0";
SqlDataSource1.Update();
}

Regarding what i assigned the parameter's default value: the "FollowUp"
field in the database is a bit. I noticed if I used .Checked?true:false it
didin't work because you can't convert bool to string. But i thought it was a
bool in the database?

just needing some help in understanding.

thanks,
rodchar
 
G

Guest

hey all,

i have the following statement:

protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{

SqlDataSource1.UpdateParameters["FollowUp"].DefaultValue=((CheckBox)sender)­.Checked?"1":"0";
SqlDataSource1.Update();
}

Regarding what i assigned the parameter's default value: the "FollowUp"
field in the database is a bit. I noticed if I used .Checked?true:false it
didin't work because you can't convert bool to string. But i thought it was a
bool in the database?

Bit is an integer data type and can be used to store 0, 1, or NULL.
 
G

Guest

but when you go into management studio you put a true or false right?

Anon User said:
hey all,

i have the following statement:

protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{

SqlDataSource1.UpdateParameters["FollowUp"].DefaultValue=((CheckBox)sender)-.Checked?"1":"0";
SqlDataSource1.Update();
}

Regarding what i assigned the parameter's default value: the "FollowUp"
field in the database is a bit. I noticed if I used .Checked?true:false it
didin't work because you can't convert bool to string. But i thought it was a
bool in the database?

Bit is an integer data type and can be used to store 0, 1, or NULL.
 
G

Guest

but when you go into management studio you put a true or false right?

Right, and I don't know why they decided to convert sql-bit to ".Net
Framework Data Type: Boolean" in a table browser of the management
studio.

I think many people are confused over the difference between True/
False and 1/0

Anyhow, use 0, or 1 to define a bit value (in this case it will be
compatible with SQL 2000).
Or use 'True', or 'False' (in apostrophes)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top