This is a migrated thread and some comments may be shown as answers.

[Solved] UpdateEdited

4 Answers 165 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ed Bassin
Top achievements
Rank 1
Ed Bassin asked on 10 Jun 2008, 04:08 PM
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);
        
    }

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 11 Jun 2008, 07:53 AM
  
0
Shinu
Top achievements
Rank 2
answered on 11 Jun 2008, 07:54 AM
Hi,

Check out the following help article.
Performing batch updates

Thanks
Shinu.
0
Ed Bassin
Top achievements
Rank 1
answered on 11 Jun 2008, 02:28 PM

0
Ed Bassin
Top achievements
Rank 1
answered on 11 Jun 2008, 02:28 PM
I tried loading the values into the hashtable like in that example, but when I looped through all of the hashtable keys and printed out the associated values, all that was printed were the OLD fields.

Example:
first_name: George
last_name:  Shrub

If I edit George and change it to "Fred", the hashtable still contains the old values of first_name -->George  last_name-->Shrub
Tags
Grid
Asked by
Ed Bassin
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Ed Bassin
Top achievements
Rank 1
Share this question
or