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

Accessing GridFormItem from the GridCommandItem Refresh Button

3 Answers 95 Views
Grid
This is a migrated thread and some comments may be shown as answers.
IQworks
Top achievements
Rank 1
IQworks asked on 09 Mar 2009, 04:23 PM
  When I have an inplace form displayed to enter new data. I have two dropdownlists in the form. I also have griditem rows displayed beneath the form. 
  Currently, when I hit refresh, I set the CurrentPageIndex=0 and the first griditem record displays. But the dropdownlists lose there text's and value's and are initialized to the "Select" text.
   1) Is there a flag (or property) I can check that will let me know that the Form is currently being displayed so I can know not to rebind the grid when I hit refresh. 
   2) In my itembound, the refresh comes in as a GridCommandItem, and I cannot seem  to access the GridEditFormItem dropdownlists to refresh them with the text's and value's I need.
     I have tried various cast's but no go. I am trying to figure out how to traverse the MasterTableView to access the Form Template items. is there a more straight forward approach ? Or a combination of cast's and FindControl's that I should be looking at ?
  How can I access the form items when the current cycle is for command items ?
  thanks for any help
  David

3 Answers, 1 is accepted

Sort by
0
IQworks
Top achievements
Rank 1
answered on 10 Mar 2009, 12:14 AM
Sorry, not an inplace form, but an editform (as opposed from a pop-up).  Also, I know I can create a session variable as a flag, I was just wondering if there was something already in place that I coufld check to see that the form is already visible when the user presses Refresh. 
thanks again for your time.
0
Princy
Top achievements
Rank 2
answered on 10 Mar 2009, 05:56 AM
Hi,

You need to traverse through the GridEditFormItem collection of  the grid to access the controls in the form in The Item command event.

CS:
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    { 
      
        if (e.CommandName == RadGrid.RebindGridCommandName) 
        { 
            foreach (GridEditFormItem editedItem in RadGrid1.MasterTableView.GetItems(GridItemType.EditFormItem)) 
            { 
                TextBox txtContactName = (TextBox)editedItem["ContactName"].Controls[0]; 
            } 
        } 
    } 
 

Thanks,
Princy
0
IQworks
Top achievements
Rank 1
answered on 10 Mar 2009, 06:03 AM
Thanks Princy , that helped in more ways than one !!! 
Tags
Grid
Asked by
IQworks
Top achievements
Rank 1
Answers by
IQworks
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or