[CLOSED] Checkbox return true/false

  1. #1

    [CLOSED] Checkbox return true/false

    Hi
    I have a gridpanel with this column
    <Editor>
     <ext:Checkbox runat="server" ID="cb1"></ext:Checkbox>
    </Editor>
    and a insert that looks like this
    SqlKontaktpersoner.InsertCommand = @"INSERT INTO Table
                                               (Checkboxcol) VALUES (@cb1)";
    my sql column in a small int but the checkbox retur true/false in text, and this results in a error in the sql. Can I force the checkbox to return 1/0 instead?

    Thanks
    Mikael
    Last edited by Daniil; Oct 04, 2011 at 7:34 AM. Reason: [CLOSED]
  2. #2
    Quote Originally Posted by Jurke View Post
    Hi
    I have a gridpanel with this column
    <Editor>
     <ext:Checkbox runat="server" ID="cb1"></ext:Checkbox>
    </Editor>
    and a insert that looks like this
    
    SqlKontaktpersoner.InsertCommand = @"INSERT INTO Table
                                               (Checkboxcol) VALUES (@cb1)";
    my sql column in a small int but the checkbox retur true/false in text, and this results in a error in the sql. Can I force the checkbox to return 1/0 instead?

    Thanks
    Mikael
    Can't you create something like this:
    SqlKontaktpersoner.InsertCommand = @"INSERT INTO Table
    (Checkboxcol) VALUES (CASE WHEN @cb1 = 'true' THEN 1 ELSE 0 END)";

    Just a thought,

    Martin
    Last edited by Daniil; Oct 03, 2011 at 1:02 PM.
  3. #3
    Another solution can be:
    var myGetValue = function () {
        return this.checked ? 1 : 0;
    };
    
    <ext:Checkbox runat="server" GetValue="={myGetValue}">
    I don't think it's an elegant solution, but should work.

    I'd prefer the solution which CarWise suggested.
  4. #4
    Thanks guys!
    This works good!

    /Mikael

Similar Threads

  1. Replies: 4
    Last Post: Feb 21, 2011, 10:02 PM
  2. radio button always return false
    By hector_toy82 in forum 1.x Help
    Replies: 0
    Last Post: Nov 17, 2010, 7:11 PM
  3. Replies: 0
    Last Post: May 04, 2010, 7:08 AM
  4. [CLOSED] Disabled Checkbox is always false and shows enabled true.
    By Sharon in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Nov 12, 2009, 4:10 AM
  5. Replies: 3
    Last Post: Jan 29, 2009, 5:32 PM

Posting Permissions