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

How to Hide telerik:RadGrid EditFormSettings control runtime?

3 Answers 234 Views
Grid
This is a migrated thread and some comments may be shown as answers.
riddhish chaudhari
Top achievements
Rank 1
riddhish chaudhari asked on 03 Mar 2014, 06:36 AM
Below is my code for radgid edit form, It's working fine but i want to hide place holder control ID="plupload" on Insert/Edit mode of EditFormSettings on RadComboBox1 index chnaged event

<EditFormSettings EditFormType="Template">
<FormTemplate>
    <table id="Table2" cellspacing="2" cellpadding="1" width="100%" border="0" rules="none" style="border-collapse: collapse;">
        <tr>
            <td>
                <table id="Table4" cellspacing="1" cellpadding="1" width="50%" border="0" class="module">
                <tr>
                    <td>Name:</td>
                    <td><asp:TextBox ID="TextBox2" Text='<%# Bind( "Name") %>' runat="server" TabIndex="8"></asp:TextBox></td>
                </tr>
                <asp:PlaceHolder ID="plupload" runat="server" >
                <tr>
                    <td>File Upload :</td>
                    <td><telerik:RadAsyncUpload runat="server" ID="AsyncUpload1" OnClientFileUploaded="OnClientFileUploaded" MultipleFileSelection="Disabled"
                            AllowedFileExtensions="jpg,jpeg,png,gif" MaxFileSize="1048576" onvalidatingfile="RadAsyncUpload1_ValidatingFile"></telerik:RadAsyncUpload>
                    </td>
                </tr>
                </asp:PlaceHolder>
                </table>
            </td>
            <td>
            </td>
        </tr>
        <tr>
            <td align="right" colspan="2">
                    <asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                        runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
                    </asp:Button
                    <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel"></asp:Button>
            </td>
        </tr>
    </table>
</FormTemplate>
</EditFormSettings>

hear is my RadComboBox code

<telerik:RadComboBox ID="RadComboBox1" runat="server" onselectedindexchanged="RadComboBox1_SelectedIndexChanged" autopostback="True" >
<Items>
<telerik:RadComboBoxItem Value="1" Text="Show All" />
<telerik:RadComboBoxItem Value="2" Text="Hide File Upload" />
</Items>
</telerik:RadComboBox>

3 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 03 Mar 2014, 09:32 AM
Hi Riddhish Chaudhari,

I guess you have a RadcomboBox outside the Grid and you want a control inside editform to be accessed from that RadcomboBox . Please take a look at the following code snippet.

C#:
protected void RadComboBox1_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
    RadComboBox combo = (RadComboBox)sender;
    string value = combo.SelectedValue;
    //During EditMode
    foreach (GridDataItem item in RadGrid1.EditItems)
    {
        GridEditableItem edititem = (GridEditableItem)item.EditFormItem;   
        PlaceHolder placehldr = (PlaceHolder)edititem.FindControl("plupload");
        if (value == "2")
        {
            placehldr.Visible = false;
        }
        else
        {
            placehldr.Visible = true;
        }
    }
    //During InsertMode
    if (RadGrid1.MasterTableView.IsItemInserted)
    {
        GridEditableItem insert = (GridEditableItem)RadGrid1.MasterTableView.GetInsertItem();
        PlaceHolder ph = (PlaceHolder)insert.FindControl("plupload");
        if (value == "2")
        {
            ph.Visible = false;
        }
        else
        {
            ph.Visible = true;
        }
    }
}

Thanks,
Princy
0
riddhish chaudhari
Top achievements
Rank 1
answered on 03 Mar 2014, 11:40 AM
hey Princy, your code working great, but it's only working if i am in edit mode, every time i have to first select combobox item and then i have to go for edit/insert, can you help me to  just select only once in combobox and this functionality working until next PostBack of combobox.
0
riddhish chaudhari
Top achievements
Rank 1
answered on 03 Mar 2014, 12:16 PM
OK princy i got my problem, just i have to use your code on RadGrid1_ItemDataBound() and it's work. Thanks for help
Tags
Grid
Asked by
riddhish chaudhari
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
riddhish chaudhari
Top achievements
Rank 1
Share this question
or