Ask a Question related to ASP.NET, Design and Development.
-
Stefan #1
Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
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();
}
Stefan Guest
-
String Index Out of Range: -2
I have created a form that generates an error when i post it live and try to submit it. The action page generates an error that says: string index... -
String index out of range: -1
anyone encountered this error message with their CFLogin? I have upgraded the CF6.1 to CF7 ... -
STRING INDEX OUT OF RANGE: -12
I am using a form to upload images into the images folder. Tha path to the image it is stored into the database. all works fine on my pc using... -
string index out of range: 0
I cant see why I am getting this. I am passing some vars from one page to another and would only like to display the variable if it is defined. Here... -
index value out-of-range error
For a week, I've been stuck trying to figure out the source of this error. I've tried it so many ways; but, the error persists. Can/will someone... -
Alvin Bruney [MVP] #2
Re: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
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
[url]http://support.microsoft.com/default.aspx?scid=kb;en-us;555074[/url]
--
Regards,
Alvin Bruney
[ASP.NET MVP [url]http://mvp.support.microsoft.com/default.aspx][/url]
Got tidbits? Get it here... [url]http://tinyurl.com/27cok[/url]
"Stefan" <Stefan@Crazykode.problem> wrote in message
news:OJmCRmpdEHA.228@TK2MSFTNGP11.phx.gbl...> 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();
>
>
> }
>
>
Alvin Bruney [MVP] Guest
-
Stefan #3
Re: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
Hey folks,
Wow... After only 4 hours... I figured out the Index out of range error
and now have run into the error below ... Any help would be greatly
appreciated ...
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.
Line 256: Session["mydataset"] = dataSet1;
Line 257: // Updates the dataset table.
Line 258: r.QueueOwner= queueOwner;
Line 259:
Line 260: // Calls a SQL statement to update the database from the
dataset
Source File: c:\inetpub\wwwroot\qoupdate\qoupdate.aspx.cs Line: 258
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an
object.]
QoUpdate.WebForm1.DataGrid1_UpdateCommand(Object source,
DataGridCommandEventArgs e) in
c:\inetpub\wwwroot\qoupdate\qoupdate.aspx.cs:258
System.Web.UI.WebControls.DataGrid.OnUpdateCommand (DataGridCommandEventArgs
e)
System.Web.UI.WebControls.DataGrid.OnBubbleEvent(O bject source, EventArgs
e)
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
System.Web.UI.WebControls.DataGridItem.OnBubbleEve nt(Object source,
EventArgs e)
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
System.Web.UI.WebControls.Button.OnCommand(Command EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePo
stBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
System.Web.UI.Page.ProcessRequestMain()
KODE -
----------------------------------------------------------------------------
-----------------------------
r = dsNewsGroupID.DevComm_NG_List.FindByNewsgroupID(in t.Parse(key));
// Updates the dataset table.
r.QueueOwner= queueOwner;
"Stefan" <Stefan@Crazykode.problem> wrote in message news:...me> Hey Folks,(New to .NET)
> This is driving me NUTZ... If anyone out there can resolve this from> 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();
>
>
> }
>
>
Stefan Guest
-
Stefan #4
Re: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
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:u6iAnIrdEHA.212@TK2MSFTNGP12.phx.gbl...me> 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
> [url]http://support.microsoft.com/default.aspx?scid=kb;en-us;555074[/url]
>
> --
> Regards,
> Alvin Bruney
> [ASP.NET MVP [url]http://mvp.support.microsoft.com/default.aspx][/url]
> Got tidbits? Get it here... [url]http://tinyurl.com/27cok[/url]
> "Stefan" <Stefan@Crazykode.problem> wrote in message
> news:OJmCRmpdEHA.228@TK2MSFTNGP11.phx.gbl...> > Hey Folks,(New to .NET)
> > This is driving me NUTZ... If anyone out there can resolve this frombuttons.> > 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>> >
> > 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();
> >
> >
> > }
> >
> >
>
Stefan Guest
-
SilentCry #5
Re: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
probably not the case here but i had this same problem using Session
variables the same way you are. ie: initializing/creating them at the time
you need them. the ref books i've read say this is OK but i had problems. to
get rid of the error, i ended up having to initialize all my Session vars in
the SessionStart handler then resetting the values when necessary in my main
code.
"Stefan" <Stefan@Crazykode.problem> wrote in message
news:uNiCWFsdEHA.2696@TK2MSFTNGP09.phx.gbl...error> Hey folks,
> Wow... After only 4 hours... I figured out the Index out of rangeSystem.Web.UI.WebControls.DataGrid.OnUpdateCommand (DataGridCommandEventArgs> and now have run into the error below ... Any help would be greatly
> appreciated ...
>
>
> Exception Details: System.NullReferenceException: Object reference not set
> to an instance of an object.
>
> Line 256: Session["mydataset"] = dataSet1;
> Line 257: // Updates the dataset table.
> Line 258: r.QueueOwner= queueOwner;
> Line 259:
> Line 260: // Calls a SQL statement to update the database from the
> dataset
> Source File: c:\inetpub\wwwroot\qoupdate\qoupdate.aspx.cs Line: 258
>
> Stack Trace:
>
> [NullReferenceException: Object reference not set to an instance of an
> object.]
> QoUpdate.WebForm1.DataGrid1_UpdateCommand(Object source,
> DataGridCommandEventArgs e) in
> c:\inetpub\wwwroot\qoupdate\qoupdate.aspx.cs:258
>
>EventArgs> e)
> System.Web.UI.WebControls.DataGrid.OnBubbleEvent(O bject source,System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePo> e)
> System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
> System.Web.UI.WebControls.DataGridItem.OnBubbleEve nt(Object source,
> EventArgs e)
> System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
> System.Web.UI.WebControls.Button.OnCommand(Command EventArgs e)
>
>--> stBackEvent(String eventArgument)
> System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
> sourceControl, String eventArgument)
> System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
> System.Web.UI.Page.ProcessRequestMain()
>
>
>
>
> KODE -
> --------------------------------------------------------------------------buttons.> -----------------------------
>
> r = dsNewsGroupID.DevComm_NG_List.FindByNewsgroupID(in t.Parse(key));
> // Updates the dataset table.
>
> r.QueueOwner= queueOwner;
>
>
>
>
>
> "Stefan" <Stefan@Crazykode.problem> wrote in message news:...> me> > Hey Folks,(New to .NET)
> > This is driving me NUTZ... If anyone out there can resolve this from> > 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>> >
> > 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();
> >
> >
> > }
> >
> >
>
SilentCry Guest



Reply With Quote

