Click here to Skip to main content
15,890,579 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
model:


C#
public bool Checkbox { get; set; }



controller:

ViewBag.Checkbox = ExistingKeys.Checkbox;

C#
SqlParameter strCheckbox = new SqlParameter();
                    strCheckbox = cmdLiveBlogs.Parameters.Add("@Checkbox", SqlDbType.VarChar, 300);
                    strCheckbox.Direction = ParameterDirection.Output;


C#
Keys.Checkbox = Convert.ToBoolean(strCheckbox);



view:

Razor
@Html.CheckBoxFor(model => model.Checkbox, new {@Value = @ViewBag.Checkbox })
           @Html.Label("Enable on Website")


What I have tried:

is it returns true or false, could you please share me solution
Posted
Updated 25-Aug-16 7:36am
v2
Comments
F-ES Sitecore 25-Aug-16 6:12am    
strCheckbox is a SqlParameter object, it can't be converted to a Boolean. Google "ado.net sqlcommand output parameters" for examples on using output params, you probably need to look convert strChekbox.Value.

try this
C#
cmdLiveBlogs.ExecuteNonQuery();
Keys.Checkbox =Convert.ToBoolean(strCheckbox.Value);
 
Share this answer
 
try this
C#
cmdLiveBlogs.ExecuteNonQuery();
Keys.Checkbox =Convert.ToBoolean(strCheckbox.Value);

make sure that the @Checkbox parameter is of type bit
 
Share this answer
 
I would say both, it depend on what you have done in the UI.

You have an easy way to know, just run the code and you will see by yourself.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900