.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Using CheckBox in DataList to set checked property

Posted By:      Posted Date: September 14, 2010    Points: 0   Category :ASP.Net
  I have a field called receive e-mail, field char (1) = "Y" (Yes) out "N" (No). I am using the DataList Control CheckBox inside when you enter Edit mode code EditTemplate am placing the following code:<Asp: DataList ID = "DataList1" runat = "server ".... " ye="" closure_uid_uriylf="527"><EditItemTemplate><Asp: CheckBox ... '/> " ye="Checked='' />" closure_uid_uriylf="529">Checked ='<%# Eval ("CHR_OPTIN_SMS ")==" S"? True: false%> '/> " ye="" closure_uid_uriylf="530" mce_style="BACKGROUND-COLOR: #fff"></ EditItemTemplate>.... " ye="" closure_uid_uriylf="532" mce_style="BACKGROUND-COLOR: #fff"></ Asp: DataList>When I run the program with any records he did not show marked and should be checked when the database is "S" in the field CHR_OPTIN_SMS.Could someone help me? if the above code is correct, if not, what should I do to solve this problem.

View Complete Post

More Related Resource Links

Custom checkbox control 'checked' property is not working .


Hello ,


Iam developing a custom checkbox control deriving from the 'compositecontrol' which i need to use it for a composite control purpose.



public class TngCheckBox : CompositeControl


i have written the required properties which are working fine except the "checked" property. he

How to set the checkbox state "checked or not checked" from a database


hey In the code I have here, I need to set the checkbox state from a database but I dont know the properties:

while (l_objRead.Read())
                         //txtUserName.Text = l_objRead["UserName"].ToString().Trim();
                         txtWerknemerNaam.Text = l_objRead["Naam"].ToString().Trim();
problem here => cbAktief.CheckState = l_objRead["Aktief"];

don't know how to set the state, help pleaz :)

Checkbox Checked


I am currently trying to write some code that allows an admin to add users to a system by selecting a checkbox and then clicking a button at the top of the screen that will allow for a mass user add.  I am new to ASP and am trying to figure out how to make the system recognize each checkbox that is checked only to add to the database.  Any ideas on where to start on this?  Thanks

Html.CheckBoxFor - how can I make checkbox default checked ?

I have:Html.CheckBoxFor(model => model.available) how can I have checkbox default checked ?

Checkbox checked changed event inside gridview

Hi All, In my gridview there are 8 checkboxex in each row : 'Sunday' to 'Saturday' and one for 'All'. If 'All' is checked in a particular row, all other checkboxes in that row should be checked instantly, and viserversa. Can i do this in checkbox checked_changed event, if so how do i access the current row of the gridview in the checked changed event? Thanks in advance

Enable/Disable controls in a td when checkbox is checked

hi,I have a table with 10 rows.Each row having 3 asp controls (checkbox,textbox and dropdownlist).on pageload all controls except checkboxes should be disabled and If we check any checkbox the controls(textbox and dropdownlist) in that row are should be enable.pls reply me.Thanks in Advance.

Hyperlink navigateurl property in datalist

Hi All I have a hyperlink control in a datalist and i set the navigateurl property in the codebehind based on a service name label. Like this... Protected Sub dlServices_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles dlServices.ItemDataBound        If e.Item.ItemType = ListItemType.Item Then            If TryCast(e.Item.FindControl("ServiceNameLabel"), Label).Text = "1" Then                TryCast(e.Item.FindControl("hlServiceUrl"), HyperLink).NavigateUrl = "~/1.aspx?user=" & Request.QueryString("user")            ElseIf TryCast(e.Item.FindControl("ServiceNameLabel"), Label).Text = "2" Then                TryCast(e.Item.FindControl("hlServiceUrl"), HyperLink).NavigateUrl = "~/2.aspx?user=" & Request.QueryString("user")            End If        End If    End Sub The problem is that as the datalist is re

Validate time (MaskedEdit) if checkbox is checked

Hi,I'm using AjaxToolkit and it works just fine. In one form i'm using the Time field (MaskedEdit). I need to validate Time field only if a tickbox is ticked. Is it possible?Thanks in advance,Vladimir

Getting checked value of a checkbox created at runtime c#

Getting checked value of a checkbox created at runtime c# I use visual studio 2008, and vc# in my program i create a series of controls, inlcuding checkboxs inside an arraylist, with i=0 and increment with each control: this.arylTxtGEItems.Add(new System.Windows.Forms.CheckBox()); ((System.Windows.Forms.CheckBox)this.arylTxtGEItems[i]).Location = new System.Drawing.Point( groupBoxParametros.Location.X + 20 + (c * (w + 20)), groupBoxParametros.Location.Y + 45 + (r * (h + 16))); ((System.Windows.Forms.CheckBox)this.arylTxtGEItems[i]).Name = "CheckBox_" + i.ToString(); ((System.Windows.Forms.CheckBox)this.arylTxtGEItems[i]).Size = new System.Drawing.Size(128, 21); ((System.Windows.Forms.CheckBox)this.arylTxtGEItems[i]).TabIndex = j + 2; ((System.Windows.Forms.CheckBox)this.arylTxtGEItems[i]).Text = "&All"; ((System.Windows.Forms.CheckBox)this.arylTxtGEItems[i]).Checked = true; this.Controls.Add(((System.Windows.Forms.CheckBox)this.arylTxtGEItems[i++])); It works good, i can see my controls and use them :) The problem is that i dont know how to access a control that i created this way, for example the name of the first checkbox, is "CheckBox_0" how do i get the value of "CheckBox_0".Checked? Thank you for your help saludos rubenc  

How to use jQuery to set checkbox is checked


How do I use the jQuery set
If checkbox's value in the string (cbx1, cbx2, cbx5, cbx7),
set the checkbox is checked.
Thank you

How do I use the jQuery set

If checkbox's value in the string (cbx1, cbx2, cbx5, cbx7),

set the checkbox is checked.

Thank you

Checkbox not checked with spacebar



    In my application i am using DataGrid and as datagrid items i am using checkbox. For it i am using template as,

 <my:DataGrid Margin="10,10,10,10"
                     AutoGenerateColumns="False" RowHeaderWidth="0" 
                     FontSize="12" IsTabStop="False"                      
                     SelectionMode="Single" CanUserAddRows="False"            
                     ItemsSource="{Binding}" GridLinesVisibility="None"                   
                     Width="390" VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Standard"
                     HeadersVisibility="None" >

              <CheckBox Margin="2,0,0,0" Content="{Binding}" Width="380">

Checkbox does not remained checked



I'm having a problem with my check box on my ASP form.  When clicking on it it will execute the code attached to it (in C#) without any problems.  The issue arises when the page posts back.  When it posts back, the check box does not save its state and becomes unchecked.

Can anyone shed some light on this for me?

Thanks in advance

jquery - assign a text to a textbox when checkbox is checked by client


hi guys.

I have a checkbox on my project and I have textboxes as well. I tried some jquery code as you can see below for this function;

I would like to get the ctl00$MainContent$firstnametxt.text value to ctl00$MainContent$firstnamedrivertxt.text value when the checkbox is clicked and I want the ctl00$MainContent$firstnamedrivertxt.text to be null if the checkbox is unchecked. how can I do that? the below one doesn't work for me.

<script type="text/javascript">
    //var myspan = $('#MyCheckBoxHere');

    $('#ctl00_MainContent_CheckBox1').click(function () {

        if ($(this).is(':checked')) {
        else {

How to render a checked CheckBox to a RenderTargetBitmap ?


My checkbox is rendered without a check mark.  If I use only one checkbox (instance object) to render then I can get the check mark to show, but I cannot use this solution.  I need be able to render it using the local checkbox.  This checkbox has the Aero theme applied to it by default and this is also a must have for me.  Other themes built-in themes like Royal, and Luna render with a check mark.


<Canvas Name="canvas">
  <Button Click="Button_Click" Canvas.Left="440" Canvas.Top="

Set radio button as checked depends on the model property value


I got 3 radio-buttons:

<input type="radio" name"transport" value="taxi" checked /> Taxi <br />

<input type="radio" name"transport" value="train" /> Train <br />

<input type="radio" name"transport" value="bus" /> Bus <br />

I tried this but got error:

<input type="radio" name"transport" value="bus" <%: if (Model.Transport == "bus" ) { %> checked <:% } %>/> Bus <br />

The error was

CS1525: Invalid expression term 'if'

Any idea?

Set Checkbox.checked on modalpopup

I'm having trouble setting the checkbox.checked on a modalpopup. setting textbox.text is no problem.
Hop somebody can help me.
 <asp:Panel ID="pnlAddChild" runat="server" CssClass="Back_ModalPopup" style="display:none" Width="250" Height="350">
            <h1 class="Back_bodycontent">Add Child</h1>       
            <asp:Label ID="lblAddLabelNL" Text="Label:" runat="server" Width="50px"/>
            <asp:Textbox ID="tbAddLabelNL" runat="server" />            
            <br />
            <asp:Label ID="lblAddLinkNL" Text="Link:" runat="server" Width="50px"/>
            <asp:Textbox ID="tbAddLinkNL" runat="server" Text="http://" />
          <br />
            <asp:Label ID="lblActive" Text="Actief:" runat="server" Width="50px"/>
            <asp:PlaceHolder ID="phCHNL" runat="server" />            

Check if a checkbox is checked


When i check a checkbox i want to store some information to the database...

I write my checkbox in my Default.cs like this : "<td><INPUT TYPE='CHECKBOX'  NAME='"+ number +"' VALUE='hoi'></td>";

the number will change for every checkbox in the table.

how can i controle that i have set my checkbox?

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend