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

No Data in Rad Grid

2 Answers 133 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Fali
Top achievements
Rank 1
Fali asked on 10 Feb 2014, 02:53 AM
Hi, I'm new to telerik so please bare with me if I did any silly mistake in my code. Basically what I'm trying to do is, I need to search data's from database from the input that user have given and list it in radgrid. Below are my codes, my datatable is having all the data that I need but when the datagrid are generated, its empty. Please guide me.

<asp:Panel ID="pnlSummary" runat="server" ScrollBars="Both" Visible='false'>
          <telerik:RadAjaxPanel ID="radSummary" runat="server" Height="200px" Width="300px">
                    <telerik:RadGrid ID="dgvSummary" runat="server" AllowPaging="true" AllowSorting="true" CellSpacing="0"
                            PageSize="7" Skin="Hay">
                              <MasterTableView />
                    </telerik:RadGrid>
          </telerik:RadAjaxPanel>
</asp:Panel>

Private Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
        Dim dt As New DataTable()
        With dt.Columns
            .Add("Num.")
            .Add("Staff ID")
            .Add("Name")
            .Add("Property")
            .Add("Department")
            .Add("Position")
            .Add("Average Mark")
            .Add("Final Mark")
        End With
 
        Dim intIndex As Integer = 1
        Dim strAverage As String = "0"
        Dim strFinalAverage As String = "0"
 
        For Each objView_EvalSummaryRow As DSHREval.HREvalRow In HREvalDALC.GetEvalSummary(Me.radDepartment.SelectedValue, Me.radPosition.SelectedValue, Me.txtStarYear.Text, Me.cboStarTerm.SelectedValue)
 
            dt.Rows.Add(New Object() {intIndex, objView_EvalSummaryRow.EmpID, objView_EvalSummaryRow.EmpName, objView_EvalSummaryRow.PropertyCode, _
                                           objView_EvalSummaryRow.Department, objView_EvalSummaryRow.PresentPosition, _
                                           strAverage, strFinalAverage})
 
            intIndex += 1
        Next
 
        dgvSummary.DataSource = dt
        Me.pnlSummary.Visible = True
End Sub

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 10 Feb 2014, 04:37 AM
Hi Fali,

The grid is not bound to its values that why its empty. You need to DataBind method to bind the values to the RadGrid.

VB:
dgvSummary.DataSource = dt
dgvSummary.DataBind()
Me.pnlSummary.Visible = True

Thanks,
Princy
0
Fali
Top achievements
Rank 1
answered on 11 Feb 2014, 04:32 AM
Yes Silly me...

Thank you Princy...
Tags
Grid
Asked by
Fali
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Fali
Top achievements
Rank 1
Share this question
or