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

GridView edit mode takes numeric values only

2 Answers 52 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Pooran
Top achievements
Rank 1
Pooran asked on 16 Dec 2009, 04:30 AM

For some strange reason, the gridview edit mode for a column that is string binded, accepts only numeric values. What could be wrong

 <telerik:RadGridView Name="rgvSiteDetails" Margin="10,10,10,10" Height="340" RowIndicatorVisibility="Collapsed"   
                    ShowGroupPanel="False" AutoGenerateColumns="False" Visibility="Visible" Background="Transparent" 
                    AutoGenerateHierarchyFromDataSet="False" BorderBrush="LightGray" CanUserFreezeColumns="False" CanUserInsertRows="False" 
                    HorizontalContentAlignment="Stretch" ShowColumnHeaders="True" IsFilteringAllowed="False"   
                    VerticalGridlinesBrush="LightGray" > 
                    <telerik:RadGridView.Columns> 
                        <telerik:GridViewDataColumn UniqueName="IsSelected" DataMemberBinding="{Binding IsSelected}" Header="" Width="30" /> 
                        <telerik:GridViewDataColumn UniqueName="SiteSequence" Header="" Width="30" DataMemberBinding="{Binding SiteSequence}" /> 
                        <telerik:GridViewDataColumn UniqueName="SiteName" Header="SiteName" DataMemberBinding="{Binding SiteName}"  Width="120" /> 
                        <telerik:GridViewDataColumn UniqueName="SiteShortName" Header="SiteShortName" DataMemberBinding="{Binding SiteShortName}"  Width="120"/>  
                        <telerik:GridViewDataColumn IsReadOnly="True" UniqueName="ReceivedDate" IsVisible="True" Header="Received Date" Width="80"  DataMemberBinding="{Binding ReceivedDate}"  /> 
                        <telerik:GridViewDataColumn IsReadOnly="True" UniqueName="PatientLastName" Header="Patient Last Name" IsVisible="True" Width="120"  DataMemberBinding="{Binding PatientLastName}"  /> 
                          
                        <telerik:GridViewDataColumn x:Name="gdcCassetteId" UniqueName="CassetteID" IsVisible="False" Header="Cassette Id" Width="80"  DataMemberBinding="{Binding CassetteID}" /> 
                          
                        <telerik:GridViewDataColumn x:Name="gdcSlideId" UniqueName="DisplayName" Header="Display Name" IsVisible="False" DataMemberBinding="{Binding DisplayName}"  /> 
                        <telerik:GridViewDataColumn x:Name="gdcDisplayName" UniqueName="DisplayName" Header="Display Name" IsVisible="False" DataMemberBinding="{Binding DisplayName}"  /> 
                        <telerik:GridViewDataColumn x:Name="gdcProcedureName" UniqueName="ProcedureName" Header="Procedure Name" IsVisible="False" DataMemberBinding="{Binding DisplayName}"  /> 
                        <telerik:GridViewDataColumn x:Name="gdcLevelInfo" UniqueName="LevelInfo" Header="Level Info" IsVisible="False" DataMemberBinding="{Binding DisplayName}"  /> 
                        <telerik:GridViewDataColumn x:Name="gdcmagazineid" UniqueName="magazineid" IsVisible="False" Header="Magazine Id"  DataMemberBinding="{Binding magazineid}"  /> 
                        <telerik:GridViewDataColumn x:Name="gdcbin" UniqueName="bin" Header="Exit Bin" IsVisible="False"   DataMemberBinding="{Binding bin}"  /> 
 
                    </telerik:RadGridView.Columns> 
                </telerik:RadGridView> 
Below is the code behind

private void rgvSiteDetails_CurrentCellChanged(object sender, GridViewCurrentCellChangedEventArgs e)  
        {  
            this.rgvSiteDetails.BeginEdit();  
        } 
 SharedData.lstSelectedCaseData = new ObservableCollection<SharedData.SelectedCaseData>();  
 
                rgvSiteDetails.DataLoaded += new EventHandler<EventArgs>(rgvSiteDetails_DataLoaded);  
               foreach (CaseDataCase item in SharedData.objCurrent.Items)  
                        {  
                            if (item.Specimen != null)  
                                foreach (CaseDataCaseSpecimen item2 in item.Specimen)  
                                {  
                                    SharedData.SelectedCaseData a = new SharedData.SelectedCaseData();  
                                    a.CaseId = item.CaseId;  
                                    a.AccessionNumber = item.AccessionNumber;  
                                    a.ReceivedDate = item.ReceivedDate;  
                                    a.PatientLastName = item.Patient[0].PatientLastName;  
                                    a.IsSelected = true;  
                                    a.SiteName = item2.SiteName;  
                                    a.SiteSequence = item2.SiteSequence;  
                                    a.SiteShortName = item2.SiteShortName;  
                                    a.SiteID = item2.SiteID;  
                                    SharedData.lstSelectedCaseData.Add(a);         
                                }  
                              
                        }  
                        rgvSiteDetails.ItemsSource = SharedData.lstSelectedCaseData; 

void rgvSiteDetails_DataLoaded(object sender, EventArgs e)  
        {  
            try 
            {  
                SharedData.Log.Info("Entering rgvSiteDetails_DataLoaded");  
                rgvSiteDetails.ExpandAllGroups();  
                SharedData.Log.Info("Exiting rgvSiteDetails_DataLoaded");  
            }  
            catch (Exception ex)  
            {  
                SharedMethods.HandleExceptions(ex);  
            }  
              
        } 

Any help would be highly appreciated.
Pooran

2 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 16 Dec 2009, 01:25 PM
Hi Pooran,

 Can you post more info about the exact column which is causing this problem + column binding property declaration?


All the best,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Pooran
Top achievements
Rank 1
answered on 17 Dec 2009, 03:46 AM

My mistake.. there was one piece of code which was for other textbox.

         protected override void OnPreviewTextInput(System.Windows.Input.TextCompositionEventArgs e)  
        {  
            try 
            {  
                SharedData.Log.Info("Entering OnPreviewTextInput " + e.Text);  
                e.Handled = !AreAllValidNumericChars(e.Text);  
                base.OnPreviewTextInput(e);  
                SharedData.Log.Info("Exiting OnPreviewTextInput");  
            }  
            catch (Exception ex)  
            {  
                SharedData.Log.Info("Error in OnPreviewTextInput");  
                SharedMethods.HandleExceptions(ex);  
            }  
              
        }  
 
        private bool AreAllValidNumericChars(string str)  
        {  
            try 
            {  
                SharedData.Log.Info("Entering AreAllValidNumericChars " + str);  
                foreach (char c in str)  
                {  
                    if (!Char.IsNumber(c)) return false;  
                }  
                SharedData.Log.Info("Exiting AreAllValidNumericChars");  
                return true;                  
            }  
            catch (Exception ex)  
            {  
                SharedData.Log.Info("Error in AreAllValidNumericChars");  
                SharedMethods.HandleExceptions(ex);  
                return false;  
            }  
              
        } 

I think this function was also used by textbox of telerik gridview. Ideally speaking it should not.. but it is.

I have commented the above said function for now and it works.

Thanks for the pitching in for helping :)
Pooran
Tags
GridView
Asked by
Pooran
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Pooran
Top achievements
Rank 1
Share this question
or