473,385 Members | 2,044 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

OnEditCommand

I have a datagrid with an Edit button. When I click the
edit button, the app goes into the OnEditCommand sub which
calls my binddata() sub. When it gets to the .databind
line, I get the following error:

System.IndexOutOfRangeException: There is no row at
position 5.

Does anyone know why this is? It gives the error
regardless of which row I click on. (Except the position
number is different.) I call my binddata() sub in other
places and it works fine.

Here is the relevant code:

<asp:datagrid id="dgNames" runat="server"
AllowPaging="true" OnPageIndexChanged="dgNewPage"
OnEditCommand="DgNamesEdit"
OnCancelCommand="DGNamesCancel"
OnUpdateCommand="DGNamesUpdate"
AutoGenerateColumns="False" OnItemCommand="dgOK">

Sub DgNamesEdit(ByVal sender As Object, ByVal e As
DataGridCommandEventArgs)

dgNames.EditItemIndex = e.Item.ItemIndex
BindData()

End Sub
Sub BindData()

... (database connection stuff)

da.Fill(ds, "NamesList")

dgNames.DataSource = ds
dgNames.DataBind() 'error line

... (cleanup stuff)
End Sub
Nov 20 '05 #1
0 850

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: George Durzi | last post by:
cross posted in datagrid group. Inside <columns/> in my datagrid, I have the following template column <asp:templatecolumn HeaderText="To Be Completed By"> <itemtemplate> <asp:Label...
2
by: tshad | last post by:
I have multiple Grid objects that are editable on my page. The following is an example of the onEditCommand method. In this case D1 (the Grid object) is known. ...
4
by: tshad | last post by:
I am having trouble with links in my DataGrid. I have Links all over my page set to smaller and they are consistant all over the page in both Mozilla and IE, except for the DataGrid. Here is a...
0
by: Tim::.. | last post by:
Why doesn't my onEditCommand work??? I don't get an error it just doesn't do the page redirect as requested... Thanks ...CODE.. Sub LinkButton_OnClick(ByVal sender As Object, ByVal e As...
3
by: Jaime | last post by:
Hi all, I have a datagrid with 2 databound columns and one EditCommandColumn, now when I press the edit link, the correct OnEditCommand event is generated and my user defined function is called...
1
by: Mark Rae | last post by:
Guys, Apologies for asking this, but it's late and I'm clearly missing something fairly obvious... I have an <asp:DataGrid > control defined thus: <asp:DataGrid ID=dgrdResults Runat=server...
0
by: ElGordo | last post by:
I've been searching all over and think I am close, but keep getting the error "Index out of range" when trying to reference a nested datagrid when an OnEditCommand event is raised. When the...
0
by: Chris | last post by:
I've been searching all over and think I am close, but keep getting the error "Index out of range" when trying to reference a nested datagrid when an OnEditCommand event is raised. When the...
0
by: Jim in Arizona | last post by:
Is there an easier way to make a datalist aware of line breaks within text fields? I have a text box that users can type into. If they press the enter key a few times, VB sees this as a vbCrLf....
1
by: johnlim20088 | last post by:
Hi, Hi, i have a datagrid in my mypage.aspx, I used the Bound column consisted of Edit, Save, Cancel, button. When I press edit, my datagrid change to editable mode, which the Save and Cancel...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.