DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2006

    Binding checkbox checked property to a database column ASP.NET2.0


    If the checkbox is placed inside a Templatefield, then to bind it to a field in the database
    The syntax is:-
    checked = '<%# Eval("stcAccepted")%>'

    But, if I place the checkbox inside a panel on a webform (not in a datagrid 0r dataview), how can I bind its checked property to a database field, so that if it is checked "Y" should be stored in the database. If not checked then "N" should be stored. The field at the backend is of type (char(1), not null).

    Please, point to me to a good resource on the web which explians it in detail.
    I.e how will it convert the checked on check box to a "y"/"N". What code
    should be written to achieve this. And what shoulb be the sql query.


  2. #2
    Join Date
    Jul 2007

    place checklist box in a panel

    Insted of using check box ,You can use checkboxlist, then u will get. because check box and panel didnot have datasource property.

    please find my below code

    CheckBoxList1.DataSource = ds;

    CheckBoxList1.DataTextField = "YesNo";


    if (CheckBoxList1.Items[0].Text == "Y")
    CheckBoxList1.Items[0].Selected = true;
    CheckBoxList1.Items[0].Selected = false;

    below code is in aspx

    <asp:Panel ID="Panel2" runat="server" Height="50px" Width="125px">
    <asp:CheckBoxList ID="CheckBoxList1" runat="server">
    <asp:ListItem Value="YesNo"></asp:ListItem>

  3. #3
    Join Date
    Jul 2006

    I will work on it.

Similar Threads

  1. Database not properly created
    By Arjuna in forum Database
    Replies: 2
    Last Post: 07-25-2007, 03:22 AM
  2. How to Sum a column in a database
    By Jim in forum Architecture and Design
    Replies: 0
    Last Post: 03-29-2002, 10:21 AM
  3. Replies: 1
    Last Post: 11-14-2000, 09:52 AM
  4. Desiging database for checkbox fields
    By Jon Byrd in forum ASP.NET
    Replies: 2
    Last Post: 09-28-2000, 07:10 PM
  5. Replies: 1
    Last Post: 07-24-2000, 12:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.