Silverlight Page Crash + GRId Row loaded event

6 posts, 0 answers
  1. Nikhil
    Nikhil avatar
    23 posts
    Member since:
    May 2009

    Posted 29 Jul 2009 Link to this post

    Hi,

    Can you please help me with following issue ? 


    we are using SL 2.0 and most recent version of the Telerik controls. On SL page we have a telerik Grid which has a Radio Button Column. 

    We have implemented a  Search functionality on SL page , On click of Search button it calls a Web Service (with required Search criteria )  and the result received from Web Service is displayed in Telerik RAD GRId. User then select a particular Row in GRid  by Checking the Radion button corresponding for that Row and another function is called with Selected Row data as parameter.

    Grid shows 5 records at one shot and if the user needs to see more data he needs to Scroll Down in Grid , using  Grids Vertical Scroll bar  

    My application works perfectly fine if User don't do any scrolling in Telerik Grid, i.e i can call Search any number of times without any problem....every time it will call web service with out any problem.

    but if user scroll down i in Grid to see more search results .. and after that try to Search with another criteria .... My Silverlight application Crashses ..,,,,and a blank screen shows up ...i tried to debug this but it don't show any exception ...this is happenign very consistently ..if  don't do any scrolling in Telerik grid ...application works perfectly fine...but crashes if we do scrolling to select another row,,,or to see all the data and then try search again.

    Below is My GRID .XAML  and Code For ROWLOADED Event

    I have implemented following method on Rowloaded event for RadGrid ..which I have received earlier from telerik to ensure that only one Radion button is selected in the RADIO Button Column and user cannot check multiple radio buttons..with below code user can select only radio button at one time

    I also tried to comment all the code in ROWLOADED event and test my application but if i Scroll down in Telerik Grid and try searching again application crashes while calling Web Service



    1. ROWLoaded EVENT

           void RadGridView1_RowLoaded(object sender, RowLoadedEventArgs e)
            {

                if (!(e.Row is GridViewNewRow) && !(e.Row is GridViewHeaderRow))
                {
                    var cell = e.Row.Cells.Where(c => c.Column.UniqueName == "").FirstOrDefault();
                    if (cell != null)
                    {
                        var radioButton = cell.ChildrenOfType<RadioButton>().FirstOrDefault();
                        if (radioButton != null)
                        {
                            radioButton.SetBinding(RadioButton.IsCheckedProperty,
                                new Binding("IsSelected") { Source = e.Row.Record, Mode = BindingMode.TwoWay });

                            POCount = POCount + 1;
                       
                        }
                    }
                }
              
            }



    2.XAML



    <StackPanel Grid.Row="6" Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="0,35,0,0"  >

                                   <twcgv:RadGridView x:Name="RadGridView1"
                                   IsReadOnly="True" 
                                   RowIndicatorVisibility="Collapsed"
                                   AutoGenerateColumns="False"
                                   CanUserFreezeColumns="False"
                                   CanUserReorderColumns="False"
                                   ColumnsWidthMode="None"
                                   ColumnBackground="white"
                                                 
                                   ScrollMode="Deferred"
                                   UseAlternateRowStyle="True" 
                                   MultipleSelect="False"
                                   FontSize="10"
                                   MaxWidth="1060"
                                   MinWidth="1060"
                                   MinHeight="190"
                                   MaxHeight="190"
                                   Margin ="0,-30,0,0"
                                   Style="{StaticResource BPRadGridViewStyle}"
                                   RowStyle="{StaticResource RowStyle}"
                                   AlternateRowStyle="{StaticResource RowStyle_Alternate}"
                                   DataLoaded="RadGridView1_DataLoaded"
                                                                  
                                   >

                                        <twcgv:RadGridView.Columns  >
                                            <twcgv:GridViewColumn UniqueName="">
                                                <twcgv:GridViewColumn.CellTemplate>
                                                    <DataTemplate>
                                                        <RadioButton   Checked="RadioButton_Checked"  MaxWidth="20" MinWidth="20"  />
                                                    </DataTemplate>
                                                </twcgv:GridViewColumn.CellTemplate>
                                            </twcgv:GridViewColumn>

                                            <twcgv:GridViewDataColumn HeaderText="PO#" UniqueName="PONumber" Width="90" />
                                            <twcgv:GridViewDataColumn HeaderText="Vendor Name" UniqueName="VendorName" Width="200" />
                                            <twcgv:GridViewDataColumn HeaderText="Description" UniqueName="MaterialDescription" Width="200" />
                                            <twcgv:GridViewDataColumn HeaderText="Cost Center" UniqueName="CostCenter" Width="120" />
                                            <twcgv:GridViewDataColumn HeaderText="WBS" UniqueName="WBS" Width="90" />
                                            <twcgv:GridViewDataColumn HeaderText="Plant Name" UniqueName="PlantName" Width="200"/>

                                        </twcgv:RadGridView.Columns>

                                    </twcgv:RadGridView>
                                </StackPanel>


    With thanks and regards
    Nikhil Jain





















  2. Hristo
    Admin
    Hristo avatar
    830 posts
    Member since:
    Sep 2012

    Posted 03 Aug 2009 Link to this post

    Hello Nikhil,

    Could you send us the project so we can investigate this further?

    Sincerely yours,
    Hristo
    the Telerik team


    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.

  3. Simone Ravetto
    Simone Ravetto avatar
    7 posts
    Member since:
    Dec 2009

    Posted 03 Feb 2010 Link to this post

    Hi,
    I have a similar problem using Q3 controls in silverlight 3.
    I put into a GridView some data using RowLoaded method, used to set checked property in a GridViewSelectColumn. When I scroll down I have an error because some cells seems to be null.
    My code:

            private void rg_RowLoaded(object sender, RowLoadedEventArgs e)
            {
                GridViewRow row = e.Row as GridViewRow;
                string data = "example data";

                if (row != null && data != null)
                {
                        // setting checkbox value
                        if (data != null)
                            (row.Cells[0].Content as CheckBox).IsChecked = true;
                        else
                            (row.Cells[0].Content as CheckBox).IsChecked = false;
                }
            }

    Sometimes row.Cells[0].Content is null.
    Can I use direct databinding? How?

  4. Vlad
    Admin
    Vlad avatar
    11042 posts
    Member since:
    Sep 2012

    Posted 08 Feb 2010 Link to this post

    Hi,

    Since this column CheckBox is two way bound to IsSelected row property you can use this property instead and the column CheckBox will respect this immediately.

    Kind regards,
    Vlad
    the Telerik team


    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.

  5. abdul rahman
    abdul rahman avatar
    7 posts
    Member since:
    Sep 2004

    Posted 27 Mar 2010 Link to this post

    Hi ,

    I have the same problem with Q1 2010 (2010.1.309.1030)

    When ever i scroll,
     
    i get the  row.Cells[0].Content  as null.??


    Can you please help
    AR

  6. Vlad
    Admin
    Vlad avatar
    11042 posts
    Member since:
    Sep 2012

    Posted 29 Mar 2010 Link to this post

    Hello,

    I've checked this however everything worked fine on my end - the content is CheckBox.

    Kind regards,
    Vlad
    the Telerik team


    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.

Back to Top