I have 30 checkboxes in my web form, and i want to store the status of checkboxes in a array of bool. now since asp.net doesn't accept using the "checked" status of a checkbox with a variable like "i" ,problem is i don't know how to perform the code!
i want something like this:
bool[] array = new bool[30];
for (int i = 0; i < 30; i++)
{
array[i] = CheckBox(i).Checked ;
}
when you run the above code you'll get this error:
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0118: 'System.Web.UI.WebControls.CheckBox' is a 'type' but is used like a 'variable'
Source Error:
Line 109: for (int i = 0; i < 30; i++)
Line 110: {
Line 111: array[i] = CheckBox(i).Checked;
Line 112: }
Line 113:
I exactly want to know how can i use IDs of checkboxes with a variable, like:
i = 15;
CheckBox(i).Checked
instead of:
CheckBox15.Checked
ASP.net 4 and c# Thank you Guys.