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

Force grid FormTemplate open on grid load?

2 Answers 66 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 2
Dan asked on 11 May 2010, 06:15 PM
I have a RadGrid with a FormTemplate for editing the grid rows.  In one case the grid is populated with multiple rows and the user clicks the 'Edit' button on the row to invoke the editing form.  In another case the grid is populated by a single row.  In the later case, how can I instruct the grid to automatically open the editing form for the single row record when the grid is initially rendered?

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 12 May 2010, 05:37 AM

Hello Dan,

Use the following code snippet in order to put the row in EditMode based on condition.

C#:

 
    protected void Page_Load(object sender, EventArgs e)  
    {  
        if (condition) // Check for condition  
        {  
            RadGrid1.EditIndexes.Add(1);  
        }  
    } 

-Shinu.

0
Dan
Top achievements
Rank 2
answered on 12 May 2010, 01:49 PM
Shinu,  I tried your suggestion, but it did not work for me.  Did not open the edit form.  But, I found that this code did what I wanted:

protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)  
    {  
        if (condition)  
        {  
            if (!Page.IsPostBack && e.Item is GridEditableItem)  
            {  
                e.Item.Edit = true;  
            }  
        }  
    } 

Dan
Tags
Grid
Asked by
Dan
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Dan
Top achievements
Rank 2
Share this question
or