470,855 Members | 1,270 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,855 developers. It's quick & easy.

Invalid CurrentPageIndex value. It must be >= 0 and < the PageCoun

Hello, everyone. I am getting an "Invalid CurrentPageIndex value. It must be
= 0 and < the PageCount." error message when I click on the Edit button on

any pages in the datagrid besides the first one. Can someone tell me what I
am missing?

The code highlighted with an error is:
Line 204: adapter.Fill(ds);
Line 205: dgCustInfo.DataSource = ds;
Line 206: dgCustInfo.DataBind(); <----------------highlighted
Line 207: conn.Close();
Line 208:

The code on that method is:

private void editRow(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
//dgCustInfo.EditItemIndex = e.Item.ItemIndex;

SqlConnection conn = new SqlConnection
(ConfigurationSettings.AppSettings["SqlConnectionString"]);

conn.Open();

SqlCommand dataCommand = new SqlCommand();
dataCommand.Connection = conn;
dataCommand.CommandText = "SELECT GEM.customers.name AS [Institution
Name], "
+ "GEM.customers.CustomerSince AS [Customer Since], "
+ "GEM.contacts.name_first AS [First Name], "
+ "GEM.contacts.name_last AS [Last Name], "
+ "GEM.customers.address_1 AS Address, "
+ "GEM.customers.city AS City, "
+ "GEM.customers.state AS State, "
+ "GEM.customers.province AS Province, "
+ "GEM.customers.zip_code AS [Zip Code], "
+ "GEM.customers.postal_code AS [Postal Code], "
+ "GEM.customers.country AS Country, "
+ "GEM.customers.phone AS Phone, "
+ "GEM.contacts.email AS [E-mail Address], "
+ "GEM.customers.cust_id "
+ "FROM GEM.customers INNER JOIN "
+ "GEM.config_usernames ON "
+ "GEM.customers.cust_id = GEM.config_usernames.cust_id INNER JOIN "
+ "GEM.contacts ON GEM.config_usernames.contact_id =
GEM.contacts.contact_id "
+ "WHERE (GEM.customers.cust_id ='" + e.Item.Cells[16].Text + "')";

SqlDataAdapter adapter = new SqlDataAdapter(dataCommand);
DataSet ds = new DataSet();
adapter.Fill(ds);
dgCustInfo.DataSource = ds;
dgCustInfo.DataBind();
conn.Close();
}
Jun 21 '06 #1
0 1045

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Rafaela K. Azinhal | last post: by
reply views Thread by jm | last post: by
3 posts views Thread by JackO | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.