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

Vary Popup Format at Runtime

6 Answers 94 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rick
Top achievements
Rank 1
Rick asked on 11 Jul 2011, 04:36 PM
My RadGrid shows a Popup for Insert and Edit actions on a row.

In the Popup, I need to set a RadTexbox.Enabled = True/ False based on the value of a RadComboBox in the Popup.

Is there an example demonstrating this?

Thank you,

Rick

6 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 12 Jul 2011, 07:42 AM
Hello Rick,

Try the following code snippet to achieve your scenario.

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
     if (e.Item is GridEditFormItem && e.Item.IsInEditMode && !e.Item.OwnerTableView.IsItemInserted)
        {
            GridEditFormItem item = (GridEditFormItem)e.Item;
            RadComboBox combo = (RadComboBox)item.FindControl("RadComboBox1");
            if (combo.SelectedValue == "Value")
            {
                RadTextBox rtxt = (RadTextBox)item.FindControl("RadTextBox1");
                rtxt.Enabled = false;
            }
        }
 }
Thanks,
Shinu
0
Rick
Top achievements
Rank 1
answered on 12 Jul 2011, 04:31 PM
Thank you Shinu!  Your example works well.

Now, how would I get a handle to RadTextBox.Enabled in event RadComboBox.SelectedIndexChanged?

Thanks again,
Rick
0
Rick
Top achievements
Rank 1
answered on 12 Jul 2011, 05:54 PM
I should be more specific...

I have tried to get a handle to textbox like this:

Protected

Sub rcbSource_OnSelectedIndexChanged(ByVal source As Object, ByVal e As _ RadComboBoxSelectedIndexChangedEventArgs)

   Dim rtb as RadTextBox = CType(Me.FindControl("rtbName"), RadTextBox)
End Sub

 
===> But rtb returns as Nothing.  Here is the EditForm insided MasterTableView (RadGrid):
...
<EditFormSettings CaptionFormatString="Edit" CaptionDataField="id" EditFormType="Template"

InsertCaption="Insert New">

<EditColumn ButtonType="PushButton" CancelText="Cancel" UpdateText="Save" />

<PopUpSettings Modal="True" />

<FormTemplate>

<table>

  <tr>

    <td>

     <asp:Label ID="Label1" runat="server" Text="Source"></asp:Label>

    </td>

    <td>

      <telerik:RadComboBox ID="rcbSource" Runat="server" DataSourceID="sdsSources"
        
DataTextField="src_name" DataValueField="src_id" AutoPostBack="true"
        
SelectedValue='<%# Bind("src_id") %>' Skin="Black"

        OnSelectedIndexChanged="rcbSource_OnSelectedIndexChanged">

     </telerik:RadComboBox>

    </td>

  </tr>

  <tr>

    <td> </td>
    <
td>

      <telerik:RadTextBox ID="rtbName" runat="server" Text='<%# Bind("src_text") %>'></telerik:RadTextBox>

    </td>

  </tr>

  <tr

    <td> </td>

    <td>

        <telerik:RadButton ID="btnUpdate" runat="server" Text="Save" CausesValidation="True" 
            
CommandName='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "PerformInsert", "Update")%>'>

        </telerik:RadButton>

        <telerik:RadButton ID="btnCancel" runat="server" CommandName="Cancel"

            Text="Cancel">

       </telerik:RadButton>

    </td>

  </tr>

</table>  

 

</FormTemplate>

</EditFormSettings>

 

0
Lori
Top achievements
Rank 1
answered on 12 Jul 2011, 06:27 PM
Hi Rick,

I was just looking at your post, and wondered if there's a typo in the example posted here in the forum, or if this is the way it is in your project. If it is this way in your project, it seems as though you're looking for a control with the name of MyRadTextBox, but the ID of the RadTextBox is rtbName.
0
Rick
Top achievements
Rank 1
answered on 12 Jul 2011, 06:29 PM
Sorry Lori.  The posted code is edited (simplified) from the original.  I made a typo.  I'll fix it now.

I should also mention our use of nested Master pages.  I not sure how to drill down into the Telerik controls to get to rtbName.
0
Rick
Top achievements
Rank 1
answered on 12 Jul 2011, 07:10 PM
Ok, I have it working now.  I used the Parent property of the RadComboBox to get a handle to RadTextBox, its sibling.


Protected
Sub rcbSource_OnSelectedIndexChanged(ByVal source As Object, ByVal e As RadComboBoxSelectedIndexChangedEventArgs)

   Dim rcb As RadComboBox = CType(source, RadComboBox)

   Dim x As Panel rcb.Parent 
 
    Dim rtb As RadTextBox = CType(x.FindControl("rtbName"), RadTextBox)
    If rcb.SelectedItem.Text = "other" Then
        rtb.Enabled = True
    Else
        rtb.Enabled = True
    End If  

End Sub

Thanks all.
Rick
Tags
Grid
Asked by
Rick
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Rick
Top achievements
Rank 1
Lori
Top achievements
Rank 1
Share this question
or