Click here to Skip to main content
15,902,112 members
Home / Discussions / C#
   

C#

 
GeneralRe: pointer in C# Pin
3Dizard12-Jul-05 7:09
3Dizard12-Jul-05 7:09 
GeneralExcel Reporting using a Template Pin
Alomgir Miah12-Jul-05 4:34
Alomgir Miah12-Jul-05 4:34 
GeneralEventhandler Pin
pssuresh12-Jul-05 4:12
pssuresh12-Jul-05 4:12 
GeneralRe: Eventhandler Pin
S. Senthil Kumar12-Jul-05 4:39
S. Senthil Kumar12-Jul-05 4:39 
GeneralRe: Eventhandler Pin
Gavin Jeffrey12-Jul-05 4:43
Gavin Jeffrey12-Jul-05 4:43 
GeneralRe: Eventhandler Pin
Judah Gabriel Himango12-Jul-05 4:57
sponsorJudah Gabriel Himango12-Jul-05 4:57 
GeneralRe: Eventhandler Pin
J4amieC12-Jul-05 5:52
J4amieC12-Jul-05 5:52 
GeneralDatakeyfield in Datagrid Pin
livez12-Jul-05 4:07
livez12-Jul-05 4:07 
hello

I have a datagrid which consists of two columns, one templatecolumn and one boundcolumn. the templatecolumn's got two checkboxes, one in the header (when pressed it checks all checkboxes) and one for every row.
the boundcolumn shows data from a datatable. when I press a button I want to check which of the checkboxes are checked, and for everone that is, get the datakey for that row and put it in an array.

to accomplish this I do

<br />
CheckBox cb;<br />
int i = 0;<br />
foreach( DataGridItem dgi in this.MyDataGrid.Items ) <br />
{<br />
	cb = (CheckBox) dgi.Cells[0].Controls[1];<br />
	//If it's selected then add it to ArrayList<br />
	if ( cb != null && cb.Checked )  <br />
	   {<br />
             id = (int) MyDataGrid.DataKeys[i];<br />
             alSelectedValues.Add(id.ToString());<br />
	   } <br />
	i++;<br />
}<br />


but when I run program I get "Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index "

can anyone see whats wrong?

/Regards Magnus
GeneralPessimistic locking Pin
rmedo12-Jul-05 3:47
rmedo12-Jul-05 3:47 
GeneralRe: Pessimistic locking Pin
Dave Kreskowiak12-Jul-05 5:56
mveDave Kreskowiak12-Jul-05 5:56 
GeneralWi-fi Pin
jonty1912-Jul-05 3:34
jonty1912-Jul-05 3:34 
GeneralRe: Wi-fi Pin
Dave Kreskowiak12-Jul-05 5:55
mveDave Kreskowiak12-Jul-05 5:55 
GeneralRe: Wi-fi Pin
jonty1912-Jul-05 6:06
jonty1912-Jul-05 6:06 
GeneralCrystal Reports help required Pin
asmyan12-Jul-05 3:27
asmyan12-Jul-05 3:27 
GeneralWindows Service Pin
the_jebus12-Jul-05 3:18
the_jebus12-Jul-05 3:18 
GeneralRe: Windows Service Pin
Dave Kreskowiak12-Jul-05 5:52
mveDave Kreskowiak12-Jul-05 5:52 
GeneralRe: Windows Service Pin
the_jebus12-Jul-05 7:26
the_jebus12-Jul-05 7:26 
GeneralRe: Windows Service Pin
Dave Kreskowiak12-Jul-05 8:10
mveDave Kreskowiak12-Jul-05 8:10 
QuestionHow to save image of a panel with panels inside it Pin
Atlemann12-Jul-05 3:01
Atlemann12-Jul-05 3:01 
GeneralSening Keys to App using directinput Pin
moongood12-Jul-05 2:55
moongood12-Jul-05 2:55 
GeneralRe: Sening Keys to App using directinput Pin
Dave Kreskowiak12-Jul-05 5:23
mveDave Kreskowiak12-Jul-05 5:23 
GeneralC++, C#, 'main' conflict and confusion Pin
outofstock12-Jul-05 2:42
outofstock12-Jul-05 2:42 
GeneralRe: C++, C#, 'main' conflict and confusion Pin
S. Senthil Kumar12-Jul-05 4:33
S. Senthil Kumar12-Jul-05 4:33 
GeneralDatabase access Pin
parrot12312-Jul-05 2:06
parrot12312-Jul-05 2:06 
GeneralRe: Database access Pin
Alomgir Miah12-Jul-05 4:23
Alomgir Miah12-Jul-05 4:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.