faramarz_s
شنبه 29 شهریور 1382, 11:37 صبح
string name = ((TextBox)e.Item.Cells[1].Controls[0]).Text;
string family = ((TextBox)e.Item.Cells[2].Controls[0]).Text;
string fn = ((TextBox)e.Item.Cells[3].Controls[0]).Text;
string shsh1 = ((TextBox)e.Item.Cells[4].Controls[0]).Text;
string born_Date = ((TextBox)e.Item.Cells[5].Controls[0]).Text;
string Address = ((TextBox)e.Item.Cells[6].Controls[0]).Text;
string tel= ((TextBox)e.Item.Cells[7].Controls[0]).Text;
string postcode= ((TextBox)e.Item.Cells[8].Controls[0]).Text;
string faf= ((TextBox)e.Item.Cells[9].Controls[0]).Text;
string memoir = ((TextBox)e.Item.Cells[10].Controls[0]).Text;
string degree= ((TextBox)e.Item.Cells[11].Controls[0]).Text;
string un = ((TextBox)e.Item.Cells[12].Controls[0]).Text;
string gd = ((TextBox)e.Item.Cells[13].Controls[0]).Text;
string po = ((TextBox)e.Item.Cells[14].Controls[0]).Text;
string mp = ((TextBox)e.Item.Cells[15].Controls[0]).Text;
string picture = ((TextBox)e.Item.Cells[16].Controls[0]).Text;
string smd= ((TextBox)e.Item.Cells[17].Controls[0]).Text;
string emd = ((TextBox)e.Item.Cells[18].Controls[0]).Text;
SqlConnection conn =
new SqlConnection("server=(local);uid=sa;pwd=yaali;database=MDB;");
// Prepare the command text
String strCmd = "UPDATE tblCustomer SET name=N'"+
name+ "'," + "family=N'" + family+ "'," + "fn='" + fn+ "'"+
" WHERE name='" + name+"'";
SqlCommand cmd = new SqlCommand(strCmd, conn);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
// Reset the edit mode for the current item
DataGrid1.EditItemIndex = -1;
// create data source again.........
bindToDatGrid();
Specified argument was out of the range of valid values. Parameter name: index
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: index
Source Error:
Line 80: string family = ((TextBox)e.Item.Cells[2].Controls[0]).Text;
Line 81: string fn = ((TextBox)e.Item.Cells[3].Controls[0]).Text;
Line 82: string shsh1 = ((TextBox)e.Item.Cells[4].Controls[0]).Text;
Line 83: string born_Date = ((TextBox)e.Item.Cells[5].Controls[0]).Text;
Line 84: string Address = ((TextBox)e.Item.Cells[6].Controls[0]).Text;
string family = ((TextBox)e.Item.Cells[2].Controls[0]).Text;
string fn = ((TextBox)e.Item.Cells[3].Controls[0]).Text;
string shsh1 = ((TextBox)e.Item.Cells[4].Controls[0]).Text;
string born_Date = ((TextBox)e.Item.Cells[5].Controls[0]).Text;
string Address = ((TextBox)e.Item.Cells[6].Controls[0]).Text;
string tel= ((TextBox)e.Item.Cells[7].Controls[0]).Text;
string postcode= ((TextBox)e.Item.Cells[8].Controls[0]).Text;
string faf= ((TextBox)e.Item.Cells[9].Controls[0]).Text;
string memoir = ((TextBox)e.Item.Cells[10].Controls[0]).Text;
string degree= ((TextBox)e.Item.Cells[11].Controls[0]).Text;
string un = ((TextBox)e.Item.Cells[12].Controls[0]).Text;
string gd = ((TextBox)e.Item.Cells[13].Controls[0]).Text;
string po = ((TextBox)e.Item.Cells[14].Controls[0]).Text;
string mp = ((TextBox)e.Item.Cells[15].Controls[0]).Text;
string picture = ((TextBox)e.Item.Cells[16].Controls[0]).Text;
string smd= ((TextBox)e.Item.Cells[17].Controls[0]).Text;
string emd = ((TextBox)e.Item.Cells[18].Controls[0]).Text;
SqlConnection conn =
new SqlConnection("server=(local);uid=sa;pwd=yaali;database=MDB;");
// Prepare the command text
String strCmd = "UPDATE tblCustomer SET name=N'"+
name+ "'," + "family=N'" + family+ "'," + "fn='" + fn+ "'"+
" WHERE name='" + name+"'";
SqlCommand cmd = new SqlCommand(strCmd, conn);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
// Reset the edit mode for the current item
DataGrid1.EditItemIndex = -1;
// create data source again.........
bindToDatGrid();
Specified argument was out of the range of valid values. Parameter name: index
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: index
Source Error:
Line 80: string family = ((TextBox)e.Item.Cells[2].Controls[0]).Text;
Line 81: string fn = ((TextBox)e.Item.Cells[3].Controls[0]).Text;
Line 82: string shsh1 = ((TextBox)e.Item.Cells[4].Controls[0]).Text;
Line 83: string born_Date = ((TextBox)e.Item.Cells[5].Controls[0]).Text;
Line 84: string Address = ((TextBox)e.Item.Cells[6].Controls[0]).Text;