accessing data in the updatecommand

4 posts, 0 answers
  1. mww
    mww avatar
    257 posts
    Member since:
    Sep 2012

    Posted 03 Aug 2011 Link to this post

    I have a grid that binds to a list of objects. The object has an 'ArtistID' which is not displayed in the grid and is not a data key

    I need to gain access to this in the UpdateCommand event, but I just cant figure out how its done. 

    anyone help ?
  2. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 03 Aug 2011 Link to this post

    Hello mww,

    please try below code


    List<TempList > lsttemp = new List<TempList >();
    RadGrid1.DataSource = lsttemp ;

    protected void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e)
            {
                GridEditableItem editableItem = ((GridEditableItem)e.Item);
                if(editableItem.Dataitem  is TempList)
                {
                    TempList obj =(TempList) editableItem.Dataitem;
                }
            }

    let me know this code is working or not.


    Thanks,
    Jayesh Goyani
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 03 Aug 2011 Link to this post

    Hello,

    Try the following code snippet to access value in UpdateCommand event.
    C#:
    protected void RadGrid1_UpdateCommand(object sender, GridCommandEventArgs e)
    {
            GridEditableItem editItem = e.Item as GridEditableItem;
            Hashtable newValues = new Hashtable();
            e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editItem);
            string id = newValues["ArtistID"].ToString();
    }

    Thanks,
    Princy.
  5. mww
    mww avatar
    257 posts
    Member since:
    Sep 2012

    Posted 03 Aug 2011 Link to this post

    thanks, that worked
Back to Top