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

Unable to Find by DataField property

5 Answers 85 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Benjamin
Top achievements
Rank 1
Benjamin asked on 07 Oct 2008, 03:10 AM
I have the following code in my module identifying each column's UniqueName based on their DataField property. The FindByDataFieldSafe function strangely isn't able to identify TemplateColumns and would return Nothing.
Protected Function GetGridValues(ByVal rgdGrid As RadGrid, _  
                           ByVal grdEditableItem As GridEditableItem, _  
                  Optional ByVal blnValidateData As Boolean = TrueAs String  
 
Dim hshRowData As New Hashtable 
   rgdGrid.MasterTableView.ExtractValuesFromItem(hshRowData, grdEditableItem) 
   For Each strField In hshRowData.Keys  
      xmleField = xmldData.CreateElement(strField)  
         If Not rgdGrid.Columns.FindByDataFieldSafe(strField) Is Nothing Then  
            strColUniqueName = rgdGrid.Columns.FindByDataFieldSafe(strField).UniqueName  

However, if I run the following statement during debugging, using the FindUniqueNameSafe function instead, I'm able to return the value.
?cObj(rgdGrid.Columns.FindByUniqueNameSafe("colINDCUR")).DataField
"INDCUR" {String}
    String: "INDCUR"
What is wrong here?
Thanks for all the help.

5 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 09 Oct 2008, 01:37 PM
Hi Benjamin,

Can you please check if you have set the DataField property of the GridTemplateColumn?

All the best,
Rosen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Benjamin
Top achievements
Rank 1
answered on 10 Oct 2008, 02:32 AM
Yes, the column already has its DataField property defined in its ASPX code. As is the RadComboBox within it.
<radG:GridTemplateColumn UniqueName="colINDCUR" DataField="INDCUR" DataType="System.String" HeaderText="Currency" HeaderStyle-Width="10%"
   <ItemTemplate> 
      <table> 
         <asp:Label ID="lblINDCUR" runat="server" Text='<%#Bind("INDCUR")%>' Width="100%" Height="100%"/> 
      </table> 
   </ItemTemplate> 
   <EditItemTemplate> 
      <radCB:RadComboBox ID="ddlSSFXRT" runat="server" EnableLoadOnDemand="True" ExternalCallBackPage="..\..\RadGrdDDLStreamer.aspx" ItemRequestTimeout="500" Text='<%#Bind("INDCUR")%>' MaxLength="4" Skin="WindowsGray" Width="100%" DropDownWidth="300px"
         <HeaderTemplate> 
            <table style="table-layout:fixed;"
               <tr> 
                  <td style="width:15%; font: Tahoma; font-weight: bold; font-size: 9pt; text-align:center;">Code</td> 
                  <td style="width:85%; font: Tahoma; font-weight: bold; font-size: 9pt;">Currency</td> 
               </tr> 
            </table> 
         </HeaderTemplate> 
   </radCB:RadComboBox> 
</EditItemTemplate> 
</radG:GridTemplateColumn> 

The screen works fine actually, but I needed a new method of identifying and validating each of the column's data. It was during my R&D where I discovered this issue. So far I've made a fix around this bug, but I'm not comfortable with leaving this unsolved, for fear it could return to haunt any future development. Thanks for your time.

0
Nikolay Rusev
Telerik team
answered on 13 Oct 2008, 01:33 PM
Hello Benjamin,

Please find the attached project to this forum post.
It seems like RadGrid1.Columns.FindAllByDataField is working as expected.

Regards,
Nikolay
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Benjamin
Top achievements
Rank 1
answered on 14 Oct 2008, 03:05 AM
But it was FindByDataFieldSafe method where I discovered this issue. Does FindAllByDataField method operate on the same codes and does that confirm the issue doesn't happen for FindByDataFieldSafe method?
0
Nikolay Rusev
Telerik team
answered on 14 Oct 2008, 12:28 PM
Hello Benjamin,

Please excuse me for the mistake. However, if you replace FindAllByDataField  with FindByDataFieldSafe you will see that GridTemplateColumn will be found in the example which I sent you in my previous post.

Regards,
Nikolay
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Benjamin
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Benjamin
Top achievements
Rank 1
Nikolay Rusev
Telerik team
Share this question
or