AspdotnetCodes.com
Search
Articles
Books
Resources
Asp.Net News
Downloads
Free Tech Magazines
Asp.Net Web Hosting
Archives
Softwares
Newsletter
Suggest Us
Link to Us
Feeds Subscription
Articles
Questions & Answers
Tips & Tricks
 Gridviews Using HoverMenu
Posted by sreenuvedala on  11/3/2008 6:04:15 AM Category: AJAX
Add to my favorites
Email to friend
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString());
string cust_name, cust_loc;
int cust_id;

cust_name = ((TextBox)GridView1.Rows[e.RowIndex].Cells[2].Controls[0]).Text;
cust_loc = ((TextBox)GridView1.Rows[e.RowIndex].Cells[3].Controls[0]).Text;
cust_id = Convert.ToInt32(GridView1.Rows[e.RowIndex].Cells[1].Text);
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "update customer set cust_name='" + cust_name + "', cust_loc='" + cust_loc + "' where cust_id=" + cust_id;
cmd.Connection = con;
con.Open();

cmd.ExecuteNonQuery();
con.Close();
GridView1.EditIndex = -1;
fill();
}

When I click on Update Link Button, i am getting a error like....
"
An exception of type 'System.ArgumentOutOfRangeException' occurred in System.Web.dll but was not handled in user code

Additional information: Specified argument was out of the range of valid values.
"
can i know the reason why it is happening like this???

when i tried in manual gridview implementation it works properly....but when i use HOVERMENU i am getting this ERROR.

please help me to solve the error.

Thanks in Advance.....sreenuvedala@gmail.com


Post Your Reply Post New Question

 Viewer's Reply
Check the Index of the Cells
Answered By Moderator1 on 11/4/2008 7:37:27 AM
Hi,

This error is due the the Index values you used in the GridView Rows Cells to find the control. For your information, the Index of GridView Cells starts with Zero. Make sure all your 3 cells are in called properly in RowUpdating.
 
Post Your Reply If you still have problem, post it again under this reply for better response.

 
Sponsored by
Everything You Know About CSS Is Wrong! - Free 37 Page Preview!
Easing the Migration to Microsoft SQL Server 2005
Backup and Recovery Best Practices for Microsoft SQL Server 2005