Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

Reply
Thread Tools

Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

 
 
Stefan
Guest
Posts: n/a
 
      07-31-2004
Hey Folks,(New to .NET)
This is driving me NUTZ... If anyone out there can resolve this from me
I would greatly appreciate it...

Line 238:
Line 239: // Gets the value of the key field of the row being updated
Line 240: string key = DataGrid1.DataKeys[e.Item.ItemIndex].ToString();
Line 241:



private void DataGrid1_UpdateCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)

{


string queueOwner;


// Gets the value of the key field of the row being updated

string key = DataGrid1.DataKeys[e.Item.ItemIndex].ToString();



// The first column -- Cells(0) -- contains the Update and Cancel buttons.

TextBox tb;

// Gets the value the TextBox control in the third column

tb = (TextBox)(e.Item.Cells[3].Controls[0]);

queueOwner = tb.Text;

dsNewsGroupID.DevComm_NG_ListRow r;

r = dsNewsGroupID.DevComm_NG_List.FindByNewsgroupID(in t.Parse(key));

// Updates the dataset table.

r.QueueOwner = queueOwner;


// Calls a SQL statement to update the database from the dataset

sqlDataAdapter1.Update(dataSet1);

// Takes the DataGrid row out of editing mode

DataGrid1.EditItemIndex = -1;

// Refreshes the grid

DataGrid1.DataBind();


}


 
Reply With Quote
 
 
 
 
Alvin Bruney [MVP]
Guest
Posts: n/a
 
      07-31-2004
first of all, you don't need to post this all over the internet, one well
chosen newsgroup will do nicely.
here is an article describing your problem
http://support.microsoft.com/default...b;en-us;555074

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"Stefan" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hey Folks,(New to .NET)
> This is driving me NUTZ... If anyone out there can resolve this from me
> I would greatly appreciate it...
>
> Line 238:
> Line 239: // Gets the value of the key field of the row being updated
> Line 240: string key = DataGrid1.DataKeys[e.Item.ItemIndex].ToString();
> Line 241:
>
>
>
> private void DataGrid1_UpdateCommand(object source,
> System.Web.UI.WebControls.DataGridCommandEventArgs e)
>
> {
>
>
> string queueOwner;
>
>
> // Gets the value of the key field of the row being updated
>
> string key = DataGrid1.DataKeys[e.Item.ItemIndex].ToString();
>
>
>
> // The first column -- Cells(0) -- contains the Update and Cancel buttons.
>
> TextBox tb;
>
> // Gets the value the TextBox control in the third column
>
> tb = (TextBox)(e.Item.Cells[3].Controls[0]);
>
> queueOwner = tb.Text;
>
> dsNewsGroupID.DevComm_NG_ListRow r;
>
> r = dsNewsGroupID.DevComm_NG_List.FindByNewsgroupID(in t.Parse(key));
>
> // Updates the dataset table.
>
> r.QueueOwner = queueOwner;
>
>
> // Calls a SQL statement to update the database from the dataset
>
> sqlDataAdapter1.Update(dataSet1);
>
> // Takes the DataGrid row out of editing mode
>
> DataGrid1.EditItemIndex = -1;
>
> // Refreshes the grid
>
> DataGrid1.DataBind();
>
>
> }
>
>



 
Reply With Quote
 
 
 
 
Stefan
Guest
Posts: n/a
 
      07-31-2004
Hey Alvin,
Thanks for the followup ... It turns out the DataKeyField was showing
empty... So I added the DataKeyField with primary key ..

AutoGenerateColumns="False" DataSource="<%# dataSet1 %>"
DataKeyField="NewsGroupID" Visible="False" Font-Names="Arial">

If anyone has any assistance on my other error... All I have to do is get by
that error and I am done... :0) hopefully ...

Thanks
Stefan

"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:(E-Mail Removed)...
> first of all, you don't need to post this all over the internet, one well
> chosen newsgroup will do nicely.
> here is an article describing your problem
> http://support.microsoft.com/default...b;en-us;555074
>
> --
> Regards,
> Alvin Bruney
> [ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
> Got tidbits? Get it here... http://tinyurl.com/27cok
> "Stefan" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hey Folks,(New to .NET)
> > This is driving me NUTZ... If anyone out there can resolve this from

me
> > I would greatly appreciate it...
> >
> > Line 238:
> > Line 239: // Gets the value of the key field of the row being updated
> > Line 240: string key = DataGrid1.DataKeys[e.Item.ItemIndex].ToString();
> > Line 241:
> >
> >
> >
> > private void DataGrid1_UpdateCommand(object source,
> > System.Web.UI.WebControls.DataGridCommandEventArgs e)
> >
> > {
> >
> >
> > string queueOwner;
> >
> >
> > // Gets the value of the key field of the row being updated
> >
> > string key = DataGrid1.DataKeys[e.Item.ItemIndex].ToString();
> >
> >
> >
> > // The first column -- Cells(0) -- contains the Update and Cancel

buttons.
> >
> > TextBox tb;
> >
> > // Gets the value the TextBox control in the third column
> >
> > tb = (TextBox)(e.Item.Cells[3].Controls[0]);
> >
> > queueOwner = tb.Text;
> >
> > dsNewsGroupID.DevComm_NG_ListRow r;
> >
> > r = dsNewsGroupID.DevComm_NG_List.FindByNewsgroupID(in t.Parse(key));
> >
> > // Updates the dataset table.
> >
> > r.QueueOwner = queueOwner;
> >
> >
> > // Calls a SQL statement to update the database from the dataset
> >
> > sqlDataAdapter1.Update(dataSet1);
> >
> > // Takes the DataGrid row out of editing mode
> >
> > DataGrid1.EditItemIndex = -1;
> >
> > // Refreshes the grid
> >
> > DataGrid1.DataBind();
> >
> >
> > }
> >
> >

>
>



 
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
Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index" camelean@shaw.ca ASP .Net 3 02-22-2011 07:06 PM
Index was out of range. Must be non-negative and less than the sizeof the collection. biswal.srikant@gmail.com ASP .Net 0 10-20-2008 10:59 AM
Index was out of range. Must be non-negative and less than the size of the collection Error Pat ASP .Net 0 09-27-2005 11:38 PM
Index was out of range. Must be non-negative and less than the size of the collection. karunakar ASP .Net 0 02-16-2005 10:06 AM
ALL MUST READ!!! -- Works in less than 24hrs Linh Computer Support 6 03-07-2004 01:15 PM



Advertisments