473,406 Members | 2,345 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,406 software developers and data experts.

'There is no row at position 0'

I have a DataGrid and am attempting to have in-grid data editing. At
the moment I'm working with a single DropDownList:

public void roleList_Update(Object sender,
DataGridCommandEventArgs e)
{
int newRoleID = 666;

DropDownList ddl = (DropDownList)
e.Item.FindControl("ddlRoleEdit");

if (ddl != null)

newRoleID = int.Parse(ddl.SelectedValue);
roleListRowSQLAdapter.SelectCommand.Parameters["@currentRow"].Value =
(int) roleList.DataKeys[e.Item.ItemIndex];

roleListRowSQLAdapter.Fill(roleListRowDataSet);

roleListRowDataSet.ContactRoleDetailRow crd =
roleListRowDataSet.ContactRoleDetail[0]; /* BOOM! */
crd.Role = ddl.SelectedValue;
roleListRowSQLAdapter.Update(roleListRowDataSet.Co
ntactRoleDetail);
}

The commented line above is where the code breaks; the page complains
that 'There is no row at position 0.' Now, I understand this to mean
rowListRowDataSet is empty. But why? It was generated from an SQL
adapter and a SELECT statement I'm sure works. The parameter
@currentRow is valid, too. Isn't the 'Generate Dataset...' command all
that's needed to make a functioning DataSet? I'm picking this stuff up
by myself, so I may be missing some crucial idea.

Thanks!
Dec 14 '07 #1
2 3830


<wi**********@gmail.comwrote in message
news:d0**********************************@i29g2000 prf.googlegroups.com...
I have a DataGrid and am attempting to have in-grid data editing. At
the moment I'm working with a single DropDownList:

public void roleList_Update(Object sender,
DataGridCommandEventArgs e)
{
int newRoleID = 666;

DropDownList ddl = (DropDownList)
e.Item.FindControl("ddlRoleEdit");

if (ddl != null)

newRoleID = int.Parse(ddl.SelectedValue);
roleListRowSQLAdapter.SelectCommand.Parameters["@currentRow"].Value =
(int) roleList.DataKeys[e.Item.ItemIndex];

roleListRowSQLAdapter.Fill(roleListRowDataSet);

roleListRowDataSet.ContactRoleDetailRow crd =
roleListRowDataSet.ContactRoleDetail[0]; /* BOOM! */
crd.Role = ddl.SelectedValue;
roleListRowSQLAdapter.Update(roleListRowDataSet.Co
ntactRoleDetail);
}

The commented line above is where the code breaks; the page complains
that 'There is no row at position 0.' Now, I understand this to mean
rowListRowDataSet is empty. But why? It was generated from an SQL
adapter and a SELECT statement I'm sure works. The parameter
@currentRow is valid, too. Isn't the 'Generate Dataset...' command all
that's needed to make a functioning DataSet? I'm picking this stuff up
by myself, so I may be missing some crucial idea.

Thanks!
Well, there are a couple of things to try. What I would suggest is that you
perform a debug run and step through each line in that code to verify all
the values you expect are indeed the values being used (for example,
ddl.SelectedValue). Something I don't see is the code you use to create the
data adapter....that could have something to do with it as well, but we
can't tell because you didn't include it.

HTH,
Mythran
Dec 14 '07 #2
On Dec 14, 10:29 am, "Mythran" <kip_pot...@hotmail.comwrote:
<william.o...@gmail.comwrote in message

news:d0**********************************@i29g2000 prf.googlegroups.com...
I have a DataGrid and am attempting to have in-grid data editing. At
the moment I'm working with a single DropDownList:
public void roleList_Update(Object sender,
DataGridCommandEventArgs e)
{
int newRoleID = 666;
DropDownList ddl = (DropDownList)
e.Item.FindControl("ddlRoleEdit");
if (ddl != null)
newRoleID = int.Parse(ddl.SelectedValue);
roleListRowSQLAdapter.SelectCommand.Parameters["@currentRow"].Value =
(int) roleList.DataKeys[e.Item.ItemIndex];
roleListRowSQLAdapter.Fill(roleListRowDataSet);
roleListRowDataSet.ContactRoleDetailRow crd =
roleListRowDataSet.ContactRoleDetail[0]; /* BOOM! */
crd.Role = ddl.SelectedValue;
roleListRowSQLAdapter.Update(roleListRowDataSet.Co
ntactRoleDetail);
}
The commented line above is where the code breaks; the page complains
that 'There is no row at position 0.' Now, I understand this to mean
rowListRowDataSet is empty. But why? It was generated from an SQL
adapter and a SELECT statement I'm sure works. The parameter
@currentRow is valid, too. Isn't the 'Generate Dataset...' command all
that's needed to make a functioning DataSet? I'm picking this stuff up
by myself, so I may be missing some crucial idea.
Thanks!

Well, there are a couple of things to try. What I would suggest is that you
perform a debug run and step through each line in that code to verify all
the values you expect are indeed the values being used (for example,
ddl.SelectedValue). Something I don't see is the code you use to create the
data adapter....that could have something to do with it as well, but we
can't tell because you didn't include it.

HTH,
Mythran
Debugging is broken at the moment, but sending values to labels has
always worked for me. Prior to posting I had checked the most
important values: SelectCommand, @currentRow.Value, and SelectedValue,
and they all look good.

As for DataAdapter code, there really isn't much because it was
created with the Toolbox -Data -SQLDataAdapter object in Design
view. The code VS creates for the DA:

this.roleListRowSQLAdapter.SelectCommand = this.getCurrentRole;
this.roleListRowSQLAdapter.TableMappings.AddRange( new
System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "Program", new
System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("ID", "ID"),
new System.Data.Common.DataColumnMapping("Name", "Name"),
new System.Data.Common.DataColumnMapping("ShortName", "ShortName")
}
)});

And for the data set spawned from the DA:

this.roleListRowDataSet.DataSetName = "roleListRowDataSet";
this.roleListRowDataSet.Locale = new
System.Globalization.CultureInfo("en-US");
Dec 14 '07 #3

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

Similar topics

16
by: Konrad Viltersten | last post by:
Suppose you got a really long page and you'd like to enable the user (supposedly, there's only one but if it's not to difficult we could extend that to any number) not to have to scroll to the...
3
by: horusprim | last post by:
Is there a CSS absolute positioning rendering bug in FF1.02 and IE 6? I have been experimenting with precision absolute positioning in CSS. The following test content was used in the...
0
by: lucretia | last post by:
Hi, I've created a layout for an Ajax side that is "single paged" in that when the browser is resized, so is the page. The header is locked to the top, the right panel is locked to the right...
2
by: agbee1 | last post by:
Hello: I've finally made the effort to ween myself from overly using tables and use CSS for my positioning. However, I am having a problem with my navigational menu properly aligning in Firefox,...
1
by: spynx | last post by:
import javax.swing.JOptionPane; import java.io.*; import java.util.Arrays; public class election5 { public static void main( String args ) {
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.