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

[Solved] Edit grid with different popup form

2 Answers 80 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Csaba
Top achievements
Rank 1
Csaba asked on 11 Apr 2013, 09:05 AM
Hi,

I have a grid and some user roles.

I would like to do the following,

when a user would like to edit the gridrow open a popup edit form but some of the controls set disabled or invisible based on the user role.

What is the best solution with telerik controls  for this?

Thanks.

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 11 Apr 2013, 11:50 AM
Hi,

I guess you want to disable control in edit form based on your condition. Please check the following code I tried to disable a TextBox inside the edit form(GridBoundColumn).

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridEditableItem && e.Item.IsInEditMode)
    {
        GridEditableItem edit = (GridEditableItem)e.Item;
        if(your condition)
        {
            TextBox txt = (TextBox)edit["OrderID"].Controls[0];
            txt.Enabled = false;
        }
    }
}

Thanks,
Princy.
0
Csaba
Top achievements
Rank 1
answered on 12 Apr 2013, 02:56 PM
Thanks.
It's works.

And if I use template type edit form?
Because your code throw the following exception in this case:
'Specified argument was out of the range of valid values.Parameter name: index'

the following code is good?
TextBox txt = (TextBox)edit.FindControl("OrderID");

It's works fine, but I don't know that this is the best solution.

Thanks.

Tags
Grid
Asked by
Csaba
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Csaba
Top achievements
Rank 1
Share this question
or