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

Changing the EditForm .ascx based on what grid called it

2 Answers 26 Views
Grid
This is a migrated thread and some comments may be shown as answers.
danparker276
Top achievements
Rank 2
danparker276 asked on 07 Nov 2013, 09:45 PM
So I have an address popup and I want to display some different wording or hide some textboxes based on what radGrid has called it.  Whats the best way to do this?
<MasterTableView EditMode="PopUp" CommandItemDisplay="Top"  DataKeyNames="AddressId">
 
                   <EditFormSettings  UserControlName="~/AddressEdit.ascx" EditFormType="WebUserControl" InsertCaption="Add new Address" PopUpSettings-Width="800px"
        FormStyle-BackColor="AliceBlue" FormStyle-BorderWidth="5px" FormStyle-BorderColor="Turquoise" CaptionFormatString="Edit Address ID: {0}"
        CaptionDataField="AddressId">
             <EditColumn UniqueName="EditCommandColumnAddr"/>
    </EditFormSettings>

2 Answers, 1 is accepted

Sort by
0
Accepted
Konstantin Dikov
Telerik team
answered on 12 Nov 2013, 04:10 PM
Hi Dan,

One possible approach for such requirement is to handle the Page_Load event of the user control and get reference to the RadGrid that is currently opening the user control:
protected void Page_Load(object sender, EventArgs e)
{
    string gridID = (NamingContainer as GridEditFormItem).OwnerGridID;
}

Once you have the ID of the grid you could add custom logic for different grids:
protected void Page_Load(object sender, EventArgs e)
{
    string gridID = (NamingContainer as GridEditFormItem).OwnerGridID;
    if (gridID == "RadGrid1")
    {
        TextBox1.Visible = false;
        Label1.Text = "Grid1 edit form";
    }
    else
    {
        Label1.Text = "Grid2 edit form";
    }
}

I have prepared a sample page for your convenience. Please refer to the attached files and see if this helps with your requirements.

 

Regards,
Konstantin Dikov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
danparker276
Top achievements
Rank 2
answered on 12 Nov 2013, 05:38 PM
Thanks, that works great.
Tags
Grid
Asked by
danparker276
Top achievements
Rank 2
Answers by
Konstantin Dikov
Telerik team
danparker276
Top achievements
Rank 2
Share this question
or