.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

How to read checkbox values from programmatically created checkboxes?

Posted By:      Posted Date: September 20, 2010    Points: 0   Category :ASP.Net

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)


View Complete Post

More Related Resource Links

How to read value of CheckBox in EXCEL sheet


I am using OLEDBConnection (@"Provider=Microsoft.ACE.OLEDB.12.0;") to connect to the EXCEL file and read contents. When I read the contents, I get all the contents from the excel sheet but i dont get contents for checkboxes placed inside.

My Excel sheet contains set of checkboxes and I need to know If they are checked or not.These checkboxes are controls which are added from Developer tab in EXCEL.

I dont want to use Excel Assemblies for reading contents as it is not recommended. And also i am using OLEDBconnection and want to stick to this .

Awaiting replies from you guys. Thanks in Advance.

How to Read values from the XAML file at Runtime

Hi , I am creating a BuildDefinition from code and Loading the Build Process template. Now,I want to read and Validate the Build Process template parameter values.When I am debuggig,I could see that these are in Xaml format. Ex: I have some value "BuildType" as "Daily" in xaml file.I want to read these values and validate them I dont know what is the bestway to read the values.Can any one please let me know how can we do it. Thanks, Srikrishna              

e.PageSettings values take too long to read.

I have an application that takes a long time to view the Print Preview on a particular user's computer.  The rest of my users don't have a problem.  I narrowed the problem down to the following line of code: Dim XOffset As Single = CSng((e.PageSettings.PaperSize.Width - e.PageSettings.Margins.Right - e.PageSettings.Margins.Left) / 2 - StringSize.Width / 2) which simply determines an X offset for a subsequent e.Drawstring that is centered. On this particular user's computer, this line of code takes between 1 and 2 seconds to execute. Another strange symptom is that once he prints the document, the print preview executes as fast as it should. Can anyone shed some light on this mysterious behavior?  Thanks!

How to start a workflow programmatically that was created in Sharepoint designer 2010?

Trying to start a workflow from code.  The workflow itself has been created in SPD 2010, which from what I understand, means that there is no assembly until the first time it's ran.  However, when I try to find the association record, that doesnt exist.  Is this becuase the 'code' hasnt been compiled yet?  If so, how can I have sharepoint start the just-in-time compiler for a declarative based workflow, so that can kick it off with in code? tia Rocky SandersRocky Sanders

Not able to save checkbox values as TRUE on record creation

I have a form I created in InfoPath 2010 on a SharePoint 2010 list. As part of this list, there are 6 yes/no columns.  Each yes/no column I have bound to a different checkbox in the InfoPath form.  In SharePoint, when I view the list and click "add new item", the blank InfoPath form appears, I edit the form and submit it.  All works fine.... EXCEPT the checkboxes.  It seems that the checkboxes always save as FALSE the first time I save a new record. If I save the new record, and then choose to "edit the item", I can set any or all of the checkboxes to true, and it works fine.  But on the initial creation of the record (using InfoPath), the checkboxes always end up being persisted as FALSE. If I create a new record directly in the list (using the datasheet view), I am able to save the yes/no fields as YES, and they persist.  So the problem really does seem to point to the InfoPath form. Any thoughts on how I can persist a TRUE value for these checkboxes when saving for the first time?

checkbox in listview layout template check select all checkboxes in listview itemtemplate

hi,how to do this when the checkbox in listview layout template check select all checkboxes in  listview itemtemplate.I dont give 'Eval 'field to checkbox present in itemtemplate.pls reply me.Many thanks in advance.

Add checkbox values to profile

I am learning how to use profiles. My profile properties are defined in web.config and wish to add selected checkboxlist values to user profiles. TextBoxes and RadioButtonLists all seem to work fine, but not my CheckBoxList values. How do I go about making this work? Regards.

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 remove 'Delete Item' from context menu of a programmatically created list?

How to remove 'Delete Item' from context menu of a programmatically created list?
I have document library which is created programmatically but now I don't want to have 'Delete Item' in context menu of that document library. Are there any possibilites?

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);

Passing numeric checkbox values into a select statement


For efficiency's sake I've created a number of stored procedures to run against an SQL table.  Which procedure runs depends upon the checkboxlist choices a user makes before clicking a button.  The checkboxlist looks something like this:

      <asp:CheckBoxList AutoPostBack="True" runat="server">

         <asp:ListItem Enabled="True" Value="1">Item 1</asp:ListItem>

         <asp:ListItem Value="10"> Item 2</asp:ListItem>

         <asp:ListItem Value="100"> Item 3</asp:ListItem>

      </asp:CheckBoxList>As an example,


What I can't figure out is how to loop through the checkboxes in the Button1_Click event in the .cs code behind page to add up the values of the selected items. (The value of an unclicked box being 0.)  Converted to a string, the totaled value is then appended to a stored procedure name (MyPROC) for entry into the SQL statement.  In other words, if the user clicks just Item 1, then the Button1_Click event would produce a stored procedure name of MyPROC1, insert it into the statement, and fire off the query; if Ite

How to read control id and values from pdf file



 I have requirement like admin will uploads some pdf files ,which contain text box ,check box ...,

similarly we will have master table which contain some matched fields.

If pdf fields mached with master table fields then i will store mached fields pdf control id's in data base , next time if i open this pdf file i need to auto fill this matched fields in pdf file.

Can any one gudie me right direction please.

Row cannot be located for updating. Some values may have been changed since it was last read


hi SharePoint Gurus,

I am deeply stuck with one issue

Description Infopatth 2007/2003: InfoPath cannot submit the form. An error occurred while the form was being submitted. Row cannot be located for updating. Some values may have been changed since it was last read

This is really frustating me as this happens only some time where as other time it is working fine. My questions are :-

1) On How to re-produce this error? Because re-produce means it can be resolved as well hopefully?

2) Secondly the possible permanent solution to this.

I have search on google & bing with no feasible solution as yet. The thread below mentioned something which doesn't help me at all.


Require Help Urgent Please !!!.

Create a year dropdownlist that with dynamically created year values


Using vb.net/asp.net 2005

I have a Year dropdownlist that I want to have the listItems created dynamically with these conditions:

1.  the oldest year selection will be "2009"

2.  all years including "2009" and the current year will be included in the listitems.

It's obvious now (at this date) that 2009 and 2010 will be the 2 current listitems, however I want this dropdownlist to automatically add all subsequent years in coming years so that there will not be the need to add a new year listitem each year.



Saving CheckBox Values from a GridView with AutoGenerated Columns


Is it possible to first add controls (ie. CheckBoxes) to a GridView with AutoGenerateColumns set to true. Then to click a single save button which loops thru the controls in the GridView, gets their values (ie. Checked/Not Checked) and then saves those values to a database?


How to read PDF using Asp.net(C#.net) and store values in Database


Dear All,

Please try to guide me how to achieve this one. my application need to do reading the PDF document and want to store the values in Database.

Actually what happens is my customers sends me the OCR scanned copied in the form of PDF file. i need to read those scanned pdf files and store the customer information into my  table.

please try to help me how to do this..

Thanking uou,



Turn on publishing programmatically when a subsite is created


I have a Site Collection with Publishing Site Template. I would like to have the publishing turned on automatically whenever a non-publishing subsite is created. Upon searching, I found there are two options. one with site definition and another with feature stapler.

I am new to .NET coding. Any code references to implement the above solution would be helpful.

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