Simple Databinding to Grid not displaying.

1 Answer 69 Views
Grid
Fred
Top achievements
Rank 2
Iron
Iron
Fred asked on 09 Nov 2022, 11:31 PM

I am attempting to populate 2 grids with simple server-side databinding to Data tables using the OnSelectedIndexChange event from another grid. I am able to verify that the data is bound to the grids. However, the grids will not display any data. No error messages are thrown.

 Thank you in advance for any help provided.

Grid Markup:

  <%-- ** This is the main Grid to pouplate "GridDiag" and "GridServices" OnSelectedIndexChange event.  --%>
                  <telerik:RadGrid ID="GridClaims" runat="server" AutoGenerateColumns="false" Width="100%" CssClass="Gridheight3" AllowPaging="false" ShowGroupPanel="false" OnSelectedIndexChanged="GridClaims_SelectedIndexChanged">
                      <ClientSettings Scrolling-AllowScroll="true" Resizing-AllowColumnResize="true" Selecting-AllowRowSelect="true" EnablePostBackOnRowClick="true">              
                      </ClientSettings>
                      <MasterTableView Name="Claims" HeaderStyle-Font-Bold="true" HeaderStyle-Font-Size="9pt" ItemStyle-Font-Size="9pt" HeaderStyle-Width="200px"> 
                          <Columns>
                              <telerik:GridBoundColumn DataField="UM_Row_ID" UniqueName="UM_Row_ID" DataType="System.Int32" Visible="false"></telerik:GridBoundColumn>
                              <telerik:GridBoundColumn DataField="Claim_Number" UniqueName="Claim_Number" DataType="System.String" HeaderText="Claim ID" ItemStyle-Font-Size="9pt"></telerik:GridBoundColumn>
                              <telerik:GridBoundColumn DataField="First_DOS" UniqueName="First_DOS" DataType="System.DateTime" DataFormatString="{0:d}" HeaderText="Start Date" ItemStyle-Font-Size="9pt"></telerik:GridBoundColumn>
                              <telerik:GridBoundColumn DataField="Last_DOS" UniqueName="Last_DOS" DataType="System.DateTime" DataFormatString="{0:d}" HeaderText="End Date" ItemStyle-Font-Size="9pt"></telerik:GridBoundColumn>
                              <telerik:GridBoundColumn DataField="Form_Type" UniqueName="Form_Type"  DataType="System.String" HeaderText="Form" ItemStyle-Font-Size="9pt"></telerik:GridBoundColumn>
                              <telerik:GridBoundColumn DataField="Claim_Status" UniqueName="Claim_Status" DataType="System.String" HeaderText="Status" ItemStyle-Font-Size="9pt"></telerik:GridBoundColumn>
                              <telerik:GridBoundColumn DataField="Clean_Date" UniqueName="Clean_Date" DataType="System.DateTime" DataFormatString="{0:d}" HeaderText="Clean Date" ItemStyle-Font-Size="9pt"></telerik:GridBoundColumn>
                              <telerik:GridBoundColumn DataField="Primary_Diag_Code" UniqueName="Primary_Diag_Code" DataType="System.String" HeaderText="Primary Diag" ItemStyle-Font-Size="9pt"></telerik:GridBoundColumn>
                              <telerik:GridBoundColumn DataField="Diag_Description" UniqueName="Diag_Description" DataType="System.String" HeaderText="Description" ItemStyle-Font-Size="9pt"></telerik:GridBoundColumn>
                              <telerik:GridBoundColumn DataField="Pay_to_Provider" UniqueName="Pay_to_Provider" DataType="System.String" HeaderText="Pay To" ItemStyle-Font-Size="9pt"></telerik:GridBoundColumn>
                              <telerik:GridBoundColumn DataField="Practitioner" UniqueName="Practitioner" DataType="System.String" HeaderText="Practitioner" ItemStyle-Font-Size="9pt"></telerik:GridBoundColumn> 
                              <telerik:GridBoundColumn DataField="Total_Amount_Billed" UniqueName="Total_Amount_Billed" DataType="System.String" HeaderText="Total Billed" ItemStyle-Font-Size="9pt"></telerik:GridBoundColumn>
                              <telerik:GridBoundColumn DataField="Total_Amount_Paid" UniqueName="Total_Amount_Paid" DataType="System.String" HeaderText="Total Paid"  ItemStyle-Font-Size="9pt"></telerik:GridBoundColumn>
                              <telerik:GridBoundColumn DataField="Payment_Date" UniqueName="Payment_Date" DataType="System.DateTime" DataFormatString="{0:d}" HeaderText="Date Paid" ItemStyle-Font-Size="9pt"></telerik:GridBoundColumn> 
                              <telerik:GridBoundColumn DataField="Approve_Deny_Date" UniqueName="Approve_Deny_Date" DataType="System.DateTime" DataFormatString="{0:d}" HeaderText="Status Date" ItemStyle-Font-Size="9pt"></telerik:GridBoundColumn>
                          </Columns>
                      </MasterTableView>
                  </telerik:RadGrid>

 <telerik:RadGrid ID="GridServices" runat="server" AutoGenerateColumns="false" Width="100%" CssClass="Gridheight4" AllowPaging="false" ShowGroupPanel="false">
                            <ClientSettings Scrolling-AllowScroll="true"> 
                                 <Resizing AllowRowResize="True" EnableRealTimeResize="True" ResizeGridOnColumnResize="false" AllowColumnResize="True"></Resizing>
                            </ClientSettings>
                              <MasterTableView Name="Services" HeaderStyle-Font-Bold="true" HeaderStyle-Font-Size="9pt" HeaderStyle-Width="200px" ItemStyle-Font-Size="9pt">
                                  <Columns>
                                      <telerik:GridBoundColumn DataField="UM_Row_ID" UniqueName="UM_Row_ID" DataType="System.Int32" Visible="false"></telerik:GridBoundColumn>
                                      <telerik:GridBoundColumn DataField="Claim_Number" UniqueName="Claim_Number" DataType="System.String" Visible="false"></telerik:GridBoundColumn>
                                      <telerik:GridBoundColumn DataField="Claim_Line" UniqueName="Claim_Line" DataType="System.Int32" HeaderText="Line #" HeaderStyle-Width="70px"></telerik:GridBoundColumn>
                                      <telerik:GridBoundColumn DataField="Service_Code" UniqueName="Service_Code" DataType="System.String" HeaderText="Svc Code"></telerik:GridBoundColumn>
                                      <telerik:GridBoundColumn DataField="Code_Description" UniqueName="Code_Description" DataType="System.String" HeaderText="Description"></telerik:GridBoundColumn>
                                      <telerik:GridBoundColumn DataField="Status" UniqueName="Status" DataType="System.String" HeaderText="Status"></telerik:GridBoundColumn>
                                      <telerik:GridBoundColumn DataField="First_DOS" UniqueName="First_DOS" DataType="System.DateTime" DataFormatString="{0:d}" HeaderText="FDOS"></telerik:GridBoundColumn>
                                      <telerik:GridBoundColumn DataField="Last_DOS" UniqueName="Last_DOS" DataType="System.DateTime" DataFormatString="{0:d}" HeaderText="LDOS"></telerik:GridBoundColumn>
                                      <telerik:GridBoundColumn DataField="POS_Code" UniqueName="POS_Code" DataType="System.String" HeaderText="POS" HeaderStyle-Width="70px"></telerik:GridBoundColumn>
                                      <telerik:GridBoundColumn DataField="Copay" UniqueName="Copay" DataType="System.String" HeaderText="Copay"></telerik:GridBoundColumn>
                                      <telerik:GridBoundColumn DataField="Amount_Billed" UniqueName="Amount_Billed" DataType="System.String" HeaderText="Charges"></telerik:GridBoundColumn>
                                      <telerik:GridBoundColumn DataField="Amount_Paid" UniqueName="Amount_Paid" DataType="System.String" HeaderText="Paid"></telerik:GridBoundColumn>
                                  </Columns>
                              </MasterTableView>
                        </telerik:RadGrid>


<telerik:RadGrid ID="GridDiag" runat="server" AutoGenerateColumns="false" Width="100%" CssClass="Gridheight4" AllowPaging="false" ShowGroupPanel="false">
                            <ClientSettings Scrolling-AllowScroll="true">  
                                 <Resizing AllowRowResize="True" EnableRealTimeResize="True" ResizeGridOnColumnResize="false" AllowColumnResize="True"></Resizing>
                            </ClientSettings>
                            <MasterTableView Name="Diags" HeaderStyle-Font-Bold="true" HeaderStyle-Font-Size="9pt" HeaderStyle-Width="200px" ItemStyle-Font-Size="9pt">
                                <Columns>
                                    <telerik:GridBoundColumn DataField="UM_Row_ID" UniqueName="UM_Row_ID" DataType="System.Int32" Visible="false"></telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="Claim_Number" UniqueName="Claim_Number" DataType="System.String" Visible="false"></telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="Diag_Number" UniqueName="Diag_Number" DataType="System.Int32" HeaderText="Sequence" HeaderStyle-Width="75px"></telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="Diag_Code" UniqueName="Diag_Code" DataType="System.String" HeaderText="Code"></telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="Description" UniqueName="Description" DataType="System.String" HeaderText="Description"></telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="Type" UniqueName="Type" DataType="System.String" HeaderText="Type"></telerik:GridBoundColumn> 
                                </Columns>
                            </MasterTableView>
                        </telerik:RadGrid>

VB.NET:

 Protected Sub GridClaims_SelectedIndexChanged(sender As Object, e As EventArgs) Handles GridClaims.SelectedIndexChanged
        Dim items As GridDataItem() = GridClaims.MasterTableView.GetSelectedItems()
        Dim ClaimID As String = items(0).Cells.Item(3).Text
        If ClaimID.Length > 9 Then
            FillDiagGrid(ClaimID)
            FillServiceGrid(ClaimID)
        End If
    End Sub

 Protected Sub FillClaimsGrid()
        'Binds the Claims Header Grid This works and displays fine
        If strSource = "UM" Then
            If dt_UM_Claims.Rows.Count > 0 Then
                GridClaims.DataSource = Nothing
                GridClaims.MasterTableView.DataSource = Nothing
                GridClaims.MasterTableView.DataSource = dt_UM_Claims.DefaultView
                GridClaims.DataSource = dt_UM_Claims.DefaultView
                GridClaims.MasterTableView.DataBind()
                GridClaims.DataBind()
            End If
End sub

Protected Sub FillDiagGrid(ByVal strClaimID As String)
        'Data is binding but does not display
        Dim vwDiag As DataView = dt_UM_Claim_Diagnosis.DefaultView
        Dim strRecord As String = txtRecordID.Text
        Dim strFilter As String = "Claim_Number = '" & strClaimID & "'"
        vwDiag.RowFilter = strFilter
        vwDiag.RowStateFilter = DataViewRowState.CurrentRows

        GridDiag.DataSource = Nothing
        GridDiag.MasterTableView.DataSource = Nothing
        GridDiag.MasterTableView.DataSource = vwDiag.Table.DefaultView
        GridDiag.MasterTableView.DataBind()
        GridDiag.DataSource = vwDiag.Table.DefaultView
        GridDiag.DataBind()
    End Sub

Protected Sub FillServiceGrid(ByVal strClaimID As String)
        'Data is binding but does not display
        Dim tblView As DataView = dt_UM_Claim_Services.DefaultView
        Dim strFilter As String = "Claim_Number = '" & strClaimID & "'"
        tblView.RowFilter = strFilter
        tblView.RowStateFilter = DataViewRowState.CurrentRows

        GridServices.DataSource = Nothing
        GridServices.MasterTableView.DataSource = Nothing
        GridServices.MasterTableView.DataSource = tblView.Table.DefaultView
        GridServices.MasterTableView.DataBind()
        GridServices.DataSource = tblView.Table.DefaultView
        GridServices.DataBind()
    End Sub

 

1 Answer, 1 is accepted

Sort by
0
Attila Antal
Telerik team
answered on 14 Nov 2022, 10:42 AM

Hi Fred,

Simple Data-binding should only be used to display a basic table.

Example

<telerik:RadGrid ID="RadGrid1" runat="server" Width="800px">
    <MasterTableView>
        <Columns>
            <telerik:GridBoundColumn DataField="Field1" HeaderText="Field 1"></telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Field2" HeaderText="Field 2"></telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Field3" HeaderText="Field 3"></telerik:GridBoundColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

VB code to bind data.

Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load

    If Not IsPostBack Then
        RadGrid1.DataSource = Enumerable.Range(1, 6).Select(Function(x) New With {
        .Field1 = "Field 1." & x,
        .Field2 = "Field 2." & x,
        .Field3 = "Field 3." & x
        }).ToList()
    End If

End Sub

 

Simple data binding will not work correctly with the Grid's functionalities, see Simple Data-binding

Simple data binding can be used in simple cases when you do not require the grid to perform complex operations such as

  • Inserting, deleting, and updating records through custom edit forms (WebUserControl or FormTemplate)
  • Grouping
  • Hierarchy relations
  • Filtering
  • Sorting
  • Paging

 

If you want to use the Grid for more than just displaying data, you must opt-in using the Programmatic Data Binding Using the NeedDataSource Event.

 

Regards,
Attila Antal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Fred
Top achievements
Rank 2
Iron
Iron
commented on 14 Nov 2022, 03:19 PM | edited

Thank you for your response Attila,

I actually figured out the problem. I placed the corresponding grids in RadAjaxLoadingPanel and added the main grid's SelectedIndexChanged event in the RadAjaxManager.  This works fine now. 


<telerik:RadAjaxManager ID="RadAjaxManger1" runat="server">
           <AjaxSettings>
               <telerik:AjaxSetting AjaxControlID="GridClaims" EventName="SelectedIndexChanged">
                   <UpdatedControls>
                       <telerik:AjaxUpdatedControl ControlID="GridDiag" LoadingPanelID="DiagLoadingPanel" />
                       <telerik:AjaxUpdatedControl ControlID="GridServices" LoadingPanelID="svcLoadingPanel" />
                   </UpdatedControls>
               </telerik:AjaxSetting>
           </AjaxSettings>
       </telerik:RadAjaxManager>

Attila Antal
Telerik team
commented on 14 Nov 2022, 03:24 PM

I am glad you managed to resolve the issue. Still, I suggest that you use the NeedDataSource event to bind data. Using Simple Data Binding will likely cause issues in the future and you will end up troubleshooting it again. Officially, Simple Data Binding is not supported for anything more than displaying simple tabular data.
Tags
Grid
Asked by
Fred
Top achievements
Rank 2
Iron
Iron
Answers by
Attila Antal
Telerik team
Share this question
or