how to retreive checkbox value from the database in aspnet using c#

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • muskan
    New Member
    • Nov 2006
    • 35

    how to retreive checkbox value from the database in aspnet using c#

    hello,

    Actually I want to retreive the checkbox value from the database.

    I have written like this:-

    Chkbillingcode =ds.Tables[0].Rows[i]["billingcod e"].ToString() ;
    But it gives error.Could u help me to solve this problem.
  • sandeepk84
    New Member
    • Oct 2006
    • 97

    #2
    Originally posted by muskan
    hello,

    Actually I want to retreive the checkbox value from the database.

    I have written like this:-

    Chkbillingcode =ds.Tables[0].Rows[i]["billingcod e"].ToString() ;
    But it gives error.Could u help me to solve this problem.
    hi..
    r u trying to check d checkbox ctrl based on d database result?
    is "Chkbillingcode " a checkbox ctrl?
    then u can have it like Chkbillingcode. Checked=true or false...
    hope this helps..
    thanx,
    sand...

    Comment

    • muskan
      New Member
      • Nov 2006
      • 35

      #3
      thanks for reply

      I have tried like that

      Chkwithdrawn.Ch ecked =ds.Tables[0].Rows[i][15].ToString();
      but it still not working .It gives the error" cannot implicitly convert object to bool"

      tell how to remove this error.

      Originally posted by sandeepk84
      hi..
      r u trying to check d checkbox ctrl based on d database result?
      is "Chkbillingcode " a checkbox ctrl?
      then u can have it like Chkbillingcode. Checked=true or false...
      hope this helps..
      thanx,
      sand...

      Comment

      • Rathorevivek
        New Member
        • Dec 2006
        • 17

        #4
        Muskan,

        Try Out:
        CheckBox1.Check ed=Convert.ToBo olean(ds.Tables[0].Rows[0]["IsVisible"].ToString());

        Originally posted by muskan
        thanks for reply

        I have tried like that

        Chkwithdrawn.Ch ecked =ds.Tables[0].Rows[i][15].ToString();
        but it still not working .It gives the error" cannot implicitly convert object to bool"

        tell how to remove this error.

        Comment

        • sandeepk84
          New Member
          • Oct 2006
          • 97

          #5
          Originally posted by muskan
          thanks for reply

          I have tried like that

          Chkwithdrawn.Ch ecked =ds.Tables[0].Rows[i][15].ToString();
          but it still not working .It gives the error" cannot implicitly convert object to bool"

          tell how to remove this error.
          Hi...
          u r gettin error b'coz Checked property of d checkbox has to b assigned a boolean value...true or false only...
          so u will have 2 convert d data retrieved frm database into bool type...
          OR
          if it can't b converted, use a boolean flag variable to hold true or false based on
          the data retrieved frm d database...for that, first retrieve d data value frm database and check it's value inorder to assign value to d boolean flag....
          hope this helps,
          thanx and rgrds
          sand...

          Comment

          • muskan
            New Member
            • Nov 2006
            • 35

            #6
            thanks for reply
            now it is working

            Originally posted by Rathorevivek
            Muskan,

            Try Out:
            CheckBox1.Check ed=Convert.ToBo olean(ds.Tables[0].Rows[0]["IsVisible"].ToString());

            Comment

            Working...