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

Reference Grid controls from outside of grid

2 Answers 152 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mike Sorel
Top achievements
Rank 1
Mike Sorel asked on 11 Jan 2011, 12:35 AM
Hi all,

I have a RadGrid setup for in place editing.  On clicking a link on the page (but outside the grid) I want to programmatically add a row to the grid and insert some values into the controls.  So far I am able to put the grid into insert mode with the following code:

            rgrdTimesheet.MasterTableView.IsItemInserted = True
            rgrdTimesheet.Rebind()

How do I then get a reference to the insert row on the RadGrid?  And then get a reference to drop down lists within template columns on the RadGrid?

Thanks in advance.

Mike

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 11 Jan 2011, 06:34 AM
Hi Mike,


The following code shows how to access control in insertform from a postback event outside grid.

Code:
protected void Button4_Click(object sender, EventArgs e)
{
    RadGrid1.MasterTableView.IsItemInserted = true// Putting in insert mode
    RadGrid1.MasterTableView.Rebind(); 
 
    GridDataInsertItem insertItem = (GridDataInsertItem)RadGrid1.MasterTableView.GetInsertItem();
    DropDownList dropDown = (DropDownList)insertItem.FindControl("DropDownList1"); // Get the control in insert form
    dropDown.Enabled = false;
}
[Where DropDownList is placed in GridTemplateColumn - EditItemTemplate]


Go through the following documentation links to know how to access the the control in edit/insert form in grid events.
Focus the text boxes in the edit control
Distinguish edit/insert mode on ItemCreated/ItemDataBound


-Shinu.
0
Mike Sorel
Top achievements
Rank 1
answered on 11 Jan 2011, 03:19 PM
Hi Shinu,

Thanks very much for your help.  All working now.

Regards
Mike
Tags
Grid
Asked by
Mike Sorel
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Mike Sorel
Top achievements
Rank 1
Share this question
or