Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Problem looping through CheckBox value in DataGrid

Reply
Thread Tools

Problem looping through CheckBox value in DataGrid

 
 
Stephan Bour
Guest
Posts: n/a
 
      12-11-2003
I was playing with this simple code strait from MSDN and I got the following
compile error:
≥foreach statement cannot operate on variables of type
'System.Web.UI.WebControls.DataList' because
'System.Web.UI.WebControls.DataList' does not contain a definition for
'GetEnumerator', or it is inaccessible"

protected void UpdateNewOligos (Object sender, EventArgs e) {
int rowCount = 0;
StringBuilder gridSelections = new StringBuilder();
foreach (DataListItem NewOrdersDataListItem in NewOrdersDataList) {
CheckBox chkSelectNew =
(CheckBox)NewOrdersDataListItem.Cells[0].Controls[1];
if (chkSelectNew.Checked == true) {
rowCount++;
gridSelections.AppendFormat("The checkbox for [0] was
selected<br>",
NewOrdersDataList.DataKeys[NewOrdersDataListItem.ItemIndex].ToString());
}
}
gridSelections.Append("<br>");
gridSelections.AppendFormat("Total number selected is: (0)",
rowCount.ToString());
}

Any idea?
Thanks,
Stephan.

 
Reply With Quote
 
 
 
 
Hermit Dave
Guest
Posts: n/a
 
      12-12-2003
try a normal for loop
for(int i=0; i<NewOrdersList.Count; i++)
{
DataListItem NewOrderDataItem = NewOrdersList[i];
// the rest of the code...
}

Should sort out..

Hermit Dave

"Stephan Bour" <(E-Mail Removed)> wrote in message
news:BBFE5DA1.C51B%(E-Mail Removed)...
> I was playing with this simple code strait from MSDN and I got the

following
> compile error:
> ≥foreach statement cannot operate on variables of type
> 'System.Web.UI.WebControls.DataList' because
> 'System.Web.UI.WebControls.DataList' does not contain a definition for
> 'GetEnumerator', or it is inaccessible"
>
> protected void UpdateNewOligos (Object sender, EventArgs e) {
> int rowCount = 0;
> StringBuilder gridSelections = new StringBuilder();
> foreach (DataListItem NewOrdersDataListItem in NewOrdersDataList)

{
> CheckBox chkSelectNew =
> (CheckBox)NewOrdersDataListItem.Cells[0].Controls[1];
> if (chkSelectNew.Checked == true) {
> rowCount++;
> gridSelections.AppendFormat("The checkbox for [0] was
> selected<br>",
> NewOrdersDataList.DataKeys[NewOrdersDataListItem.ItemIndex].ToString());
> }
> }
> gridSelections.Append("<br>");
> gridSelections.AppendFormat("Total number selected is: (0)",
> rowCount.ToString());
> }
>
> Any idea?
> Thanks,
> Stephan.
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
looping in array vs looping in a dic giuseppe.amatulli@gmail.com Python 5 09-20-2012 11:58 PM
looping through json array loops through the characters instead ofthe values Aaron Javascript 2 04-10-2011 05:58 PM
Looping through repeater only finds first checked checkbox, not the rest Alan Silver ASP .Net 2 07-19-2005 06:43 PM
Looping Through Controls In DataGrid Jim Heavey ASP .Net 2 12-06-2003 04:22 AM
Looping through rows in a DataGrid Diva ASP .Net 1 07-24-2003 06:10 PM



Advertisments