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

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

Getting checked value of a checkbox created at runtime c#

Posted By:      Posted Date: September 16, 2010    Points: 0   Category :Windows Application
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  

View Complete Post

More Related Resource Links

How to get Checkbox value created at runtime above gridview header


I have creted a checkbox for each column of grid at the top of the header in row created event. I need to check wheather checkbox is checked after button click event.

//Build custom header.

                GridView oGridView = (GridView)sender;
                GridViewRow oGridViewRow = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert);
                TableCell oTableCell = new TableCell();

                //Add Staff_ID
                CheckBox chkStaffID = new CheckBox();
                chkStaffID.ID = "chkStaff_ID";
                chkStaffID.Text = "Hide";
                chkStaffID.CheckedChanged += new System.EventHandler(chkStaffID_CheckedChanged);

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 ?

The Assembly was created in Runtime v1.1.4322 and cannot be loaded while runtime 4.0 without additio

Hello! Note: The text above was translated into English. I experience this problem when adding DirectX references and usings to a Form in Visual Studio 10 Professional, Trial Version. The dlls (Microsoft.DirectX; Microsoft.DirectX.Direct3D) are included from X:\Windows\Microsoft.Net\DirectX for Managed Code\1.0.2902.0\. I really like to begin coding DirectX. Do you know what this Message means? What shall I do?   Many thanks, Regards

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.

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

Using CheckBox in DataList to set checked property

  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.

How to read checkbox values from programmatically created checkboxes?


I have a form that does a loop to create checkboxes.  Here is the code in the loop:

cbxDrives.Top = TopPosition;
cbxDrives.Left = LeftPosition;
cbxDrives.Text = d.Name; 
CheckBox cbxDrives = new CheckBox();this.Controls.Add(cbxDrives);

This creates multiple check boxes on the form, and this works fine.

However, in the code behind for my button that the user clicks to execute the form, I cannot figure how how to read the values for the checkboxes.  I've tried:

foreach (CheckBox cbxDrive in cbxDrives)


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 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" />            

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

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