By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,969 Members | 1,536 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,969 IT Pros & Developers. It's quick & easy.

Programmatically using SqlDataSource

P: n/a
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
Jun 11 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Jun 11, 10:17 pm, rodchar <rodc...@discussions.microsoft.com>
wrote:
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.

Jun 11 '07 #2

P: n/a
but when you go into management studio you put a true or false right?

"Alexey Smirnov" wrote:
On Jun 11, 10:17 pm, rodchar <rodc...@discussions.microsoft.com>
wrote:
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.

Jun 12 '07 #3

P: n/a
On Jun 12, 3:16 pm, rodchar <rodc...@discussions.microsoft.comwrote:
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)

Jun 12 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.