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.
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.Text == "Y")
CheckBoxList1.Items.Selected = true;
CheckBoxList1.Items.Selected = false;
below code is in aspx
<asp:Panel ID="Panel2" runat="server" Height="50px" Width="125px">
<asp:CheckBoxList ID="CheckBoxList1" runat="server">
I will work on it.
By Arjuna in forum Database
Last Post: 07-25-2007, 04:22 AM
By Jim in forum Architecture and Design
Last Post: 03-29-2002, 11:21 AM
Last Post: 11-14-2000, 10:52 AM
By Jon Byrd in forum ASP.NET
Last Post: 09-28-2000, 08:10 PM
Last Post: 07-24-2000, 01:35 PM
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL