Tick on checkbox and enable textbox in Silverlight

3 posts, 0 answers
  1. lucerias
    lucerias avatar
    16 posts
    Member since:
    Nov 2011

    Posted 07 Nov 2011 Link to this post

    What is the equivalent code in ASP and Silver 4 of the following code shown as below.
     
    What i am trying to achieve is something like this. I have four columns in RadGridView, first col is CustomerID, second is CustomerName, third is CustomerAddress followed by the last col, which contains checkbox.

    When user ticks on a checkbox, the customer address textbox of a particular row will be enabled.
    When user unticks on a checkbox, the customer address textbox of a particular row will be disabled.

    May i know how to do this, thanks in advanced.


    protected void Edit(object sender, EventArgs e) 
    {
        RadTextBox textbox; 
        ChkBox checkbox = (ChkBox)sender; 
        GridItem item = (GridItem)box.NamingContainer ; 
        textbox= (RadTextBox)item.FindControl("txtEditCustAdd"); 
       
        if (checkbox.Checked) 
        {
            textbox.Enabled = true; 
        }
        else 
        {
            textbox.Enabled = false; 
            textbox.Text = ""; 
        }
      
    }
  2. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 07 Nov 2011 Link to this post

    Hi Lucerias,

    Is the checkBox in the same row as the text box or is it outside the RadGridView ?


    Kind regards,
    Pavel Pavlov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. lucerias
    lucerias avatar
    16 posts
    Member since:
    Nov 2011

    Posted 07 Nov 2011 Link to this post

    Hi,

    As i mentioned in the thread

    "What i am trying to achieve is something like this. I have four columns in RadGridView, first col is CustomerID, second is CustomerName, third is CustomerAddress followed by the last col, which contains checkbox."

    Hence, it is in the same row as the text box.
    Please let me know if you have any idea.

    xaml is shown as below.

    <Grid x:Name="LayoutRoot" SizeChanged="LayoutRoot_SizeChanged">
        <Border Background="Transparent" BorderBrush="Black" BorderThickness="1" Padding="20" Width="Auto" 
                Height="Auto">
            <Grid ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto">
                <Grid.RowDefinitions>
                    <RowDefinition Height="10" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Grid Grid.Row="1">
                    <StackPanel >
                        <telerik:RadGridView x:Name="gridCustomer"
                                EnableRowVirtualization="True" AutoGenerateColumns="False" CanUserFreezeColumns="False" ShowGroupPanel="False" MinHeight="295" MaxHeight="295"
                                CanUserResizeColumns="False" CanUserInsertRows="True" ItemsSource="{Binding}" AddingNewDataItem="gridCustomer_AddNew">
                              
                            <telerik:RadGridView.Columns>
                                <telerik:GridViewDataColumn Header="Customer Name" DataMemberBinding="{Binding CustName, Mode=TwoWay}" />
                                <telerik:GridViewDataColumn Header="Customer Description" DataMemberBinding="{Binding CustDesc, Mode=TwoWay}" />
                  
                                <telerik:GridViewDataColumn Header="Edit">
                                    <telerik:GridViewDataColumn.CellTemplate>
                                        <DataTemplate>
                                            <CheckBox IsChecked="{Binding NewAdded, Mode=TwoWay}" Checked="Edit"/>
                                        </DataTemplate>
                                    </telerik:GridViewDataColumn.CellTemplate>
                                    <telerik:GridViewDataColumn.CellEditTemplate>
                                        <DataTemplate>
                                            <CheckBox IsChecked="{Binding NewAdded, Mode=TwoWay}" Checked="Edit" />
                                        </DataTemplate>
                                    </telerik:GridViewDataColumn.CellEditTemplate>
                                      
                                </telerik:GridViewDataColumn>
                            </telerik:RadGridView.Columns>
                        </telerik:RadGridView>
                        <myclr:ucCustPager x:Name="ucCustomerPager" />
                    </StackPanel>
                </Grid>



    Thanks.
Back to Top