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

[Solved] programmatically set user control while editing radgrid

1 Answer 130 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Madhu
Top achievements
Rank 1
Madhu asked on 07 Mar 2013, 02:25 PM
Hi,
    I have two user controls - userCtrlA & userCtrlB for radgrid . While editing I want to conditionally load either of these two forms.  Is it possible? If so how?  Attached image explain the senario indetail.

Regards
Madhu

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 08 Mar 2013, 04:01 AM
Hi,

Try the following code to achieve your scenario.
C#:
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
   {
       if (e.CommandName == RadGrid.EditCommandName)
       {
           GridEditableItem item = (GridEditableItem)e.Item;
           if (item.ItemIndex%2==0)
           {
               e.Item.OwnerTableView.EditFormSettings.UserControlName = "UserControl1.ascx";
           }
           else if (item.ItemIndex % 2 != 0)
           {
               e.Item.OwnerTableView.EditFormSettings.UserControlName = "UserControl2.ascx";
           }
       }
 }

Thanks,
Shinu
Tags
Grid
Asked by
Madhu
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or