When the "update" button is pressed for a single edit form, it works. But when the "UpdateEdited" command is triggered from when the user presses it to update all of the editing rows, an exception occurs.
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: index
System.Web.UI.ControlCollection.get_Item(Int32 index) +2107838 Manage_Users.users_grid_UpdateCommand(Object source, GridCommandEventArgs e) in c:\adminui\Manage_Users.aspx.cs:37
For some reason it's not seeing the First Name control.
Here is the code I'm using:
protected void users_grid_UpdateCommand(object source, GridCommandEventArgs e)
{
GridEditableItem editedItem = e.Item as GridEditableItem;
string userid = editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["ps_userid"].ToString();
string firstName = (editedItem["First Name"].Controls[0] as TextBox).Text;
string lastName = (editedItem["Last Name"].Controls[0] as TextBox).Text;
string group = (editedItem["Group"].Controls[0] as DropDownList).SelectedItem.Text;
string updateQuery = "UPDATE ps_users set first_name='" + firstName + "',last_name='" + lastName + "',ps_usertype='" + group + "' where ps_userid='" + userid + "'";
MasterPage.executeSQL(updateQuery);
}
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: index
System.Web.UI.ControlCollection.get_Item(Int32 index) +2107838 Manage_Users.users_grid_UpdateCommand(Object source, GridCommandEventArgs e) in c:\adminui\Manage_Users.aspx.cs:37
For some reason it's not seeing the First Name control.
Here is the code I'm using:
protected void users_grid_UpdateCommand(object source, GridCommandEventArgs e)
{
GridEditableItem editedItem = e.Item as GridEditableItem;
string userid = editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["ps_userid"].ToString();
string firstName = (editedItem["First Name"].Controls[0] as TextBox).Text;
string lastName = (editedItem["Last Name"].Controls[0] as TextBox).Text;
string group = (editedItem["Group"].Controls[0] as DropDownList).SelectedItem.Text;
string updateQuery = "UPDATE ps_users set first_name='" + firstName + "',last_name='" + lastName + "',ps_usertype='" + group + "' where ps_userid='" + userid + "'";
MasterPage.executeSQL(updateQuery);
}