Find DataKeyValue

3 posts, 1 answers
  1. Roy Halvorsen
    Roy Halvorsen avatar
    83 posts
    Member since:
    Oct 2008

    Posted 14 Aug 2009 Link to this post

    I'm holding a session with a DataKeyValue (myValue) from clicking a row in a RadGrid (Grid1).
    How can I myValue to open another grid (Grid2) (on another page) in editmode (AllowMultiRowEdit=false) where the DataKeyValue of Grid2 == myValue?
  2. Roy Halvorsen
    Roy Halvorsen avatar
    83 posts
    Member since:
    Oct 2008

    Posted 14 Aug 2009 Link to this post

    Never mind. I found the answer:
        protected void RadGrid1_PreRender(object sender, EventArgs e)  
        {  
            try 
            {  
                if (!IsPostBack)  
                {  
                    if (Session["Oppgave"] != null)  
                    {  
                        var objOppgave = (Oppgave)Session["Oppgave"];  
                        foreach (GridItem item in radGrid1.MasterTableView.Items)  
                        {  
                            if (item is GridEditableItem)  
                            {  
                                GridEditableItem editableItem = item as GridDataItem;  
                                if (editableItem.GetDataKeyValue("OppgaveID").ToString() == objOppgave.OppgaveID)  
                                {  
                                    editableItem.Edit = true;  
                                    radGrid1.Rebind();  
                                    break;  
                                }  
                            }  
                        }  
                    }  
                }  
            }  
            catch (Exception exc)  
            {  
                throw exc;  
            }  
        } 
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 14 Aug 2009 Link to this post

    Hi Roy Halvorsen,

    You can try out much simpler code in ItemDataBound event to put the row in EditMode based on the session value..

    C#:
     
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            if (item.GetDataKeyValue("CustomerID").ToString() == Session["MyValue"].ToString()) 
            { 
                item.Edit = true
            } 
        } 

    -Shinu.
Back to Top