This is a migrated thread and some comments may be shown as answers.
How to clear radgrid
3 Answers 141 Views
This is a migrated thread and some comments may be shown as answers.
Kiran
Top achievements
Rank 1
Kiran asked on 10 Nov 2010, 10:48 PM
Dear there,

Somehow i have to bind the radgrid with using dataset and dataview like

Dim objDV as new dataview = nothing
Dim ds as new dataset

'after calling a function ds got somedata according to paramerters

if ds.table(0).rows.count > 0 then
    objDV = ds.tables(0).defaultview  

    RadGrid1.DataSource = objDv

else
        RadGrid1.DataSource = objDv > objdv IS NOTHING
End if

On pageload, my store procedure get all the default parameter value and grid is binding perfectly, now i am changing the param values and in the dataset i m not getting any tables and records, in this case my objdv is set = nothing but grid is carrying the same old data, not rereshing or clearing the data

where there are no records and i bind the grid like
radgrid.mastertableview.rebind

that disappears the grid

thanks and waiting for your response

please let me know what i m missing here

3 Answers, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 11 Nov 2010, 02:34 PM
Hi Kiran,

Please, make sure that you are using Advanced databindnig for the RadGrid control as opposed to Simple databinding.

All the best,
Tsvetoslav
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
0
Kiran
Top achievements
Rank 1
answered on 11 Nov 2010, 03:40 PM
thanks for your quick response.

I did try with the needdatasource here is my code,

My store procedure returns more than 1 table thats why i m using dataset instedof sqldatasource, Now when i m trying to refresh this grid by combo change, Needdatasource doesnt executed, and grid having the same old records

<telerik:RadGrid ID="RadGrid1" Width="99%" AllowSorting="true" runat="server"  ShowFooter="true" FooterStyle-CssClass="GridColHeadNormal"   >
                                                    <MasterTableView   TableLayout="Fixed"  DataKeyNames="PR_KEY" ClientDataKeyNames="PR_KEY" GroupHeaderItemStyle-Height="25" GroupsDefaultExpanded="true" GroupLoadMode="client"  >
                                                       
                                                    <Columns>
                                                       <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" />
                                                       <telerik:GridBoundColumn UniqueName="PR_KEY" DataField="PR_KEY"  ></telerik:GridBoundColumn>
                                                         
                                                       <telerik:GridBoundColumn  HeaderText="Employees" DataField="Name" UniqueName="Name" ShowFilterIcon="false" 
                                                           SortExpression="Name"  AllowFiltering="true" FilterControlWidth="100" 
                                                           AutoPostBackOnFilter="true"  />
                                                             
                                                       <telerik:GridDateTimeColumn ReadOnly="true" DataField="emp_number" HeaderText="Employee Number" ShowFilterIcon="false" 
                                                           DataType="System.String" UniqueName="empnumber" AllowFiltering="false"  SortExpression="emp_number" />
                                                         
                                                       <telerik:GridBoundColumn  DataField="NetPay" DataType="System.Double" UniqueName="NetPay"  
                                                           HeaderText="Net Pay" AllowFiltering="false"  SortExpression="NetPay"  ItemStyle-HorizontalAlign="Right">
                                                        </telerik:GridBoundColumn>
                                                            
                                                       <telerik:GridBoundColumn  HeaderText="keyid" DataField="keyid" UniqueName="keyid" AllowFiltering="false"  />
                                                       <telerik:GridBoundColumn  Aggregate="Count" HeaderText="Status" DataField="status" UniqueName="status" AllowFiltering="false" SortExpression="Status" HeaderTooltip="Click here to Group by this column" />
                                                       <telerik:GridBoundColumn  HeaderText="hds" DataField="hds" UniqueName="hds" AllowFiltering="false"  />
                                                         
                                                       </Columns>
                                                         
                                                         
                                                       </MasterTableView>
                                                         
                                                       <ClientSettings EnableRowHoverStyle="false" AllowColumnsReorder="false" ReorderColumnsOnClient="false">
                                                       <Selecting AllowRowSelect="true" UseClientSelectColumnOnly="true" />
                                                       <Scrolling SaveScrollPosition="false" UseStaticHeaders="true" ScrollHeight="350" />
                                                             
                                                       <ClientEvents   /></ClientSettings></telerik:RadGrid>
protected sub RadGrid1_NeedDatasource(byval sender as object, byVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource
        BindGrid()
    End Sub
  
Private Sub BindGrid()
  
        Dim objDv As New System.Data.DataView
        Dim objDs As New System.Data.DataSet
        Dim objPayroll As New Payroll
        Dim objCombo As New Comboclass
  
        'String to get any error returned from COM.
        Dim excep As String = ""
  
        Try
            setCon(CType(objPayroll, Object))
            setCon(CType(objCombo, Object))
            
            RadGrid1.MasterTableView.GetColumn("PR_KEY").Display = False
            RadGrid1.MasterTableView.GetColumn("hds").Display = False
            RadGrid1.MasterTableView.GetColumn("keyid").Display = False
  
            RadGrid1.MasterTableView.GetColumn("ClientSelectColumn").HeaderStyle.Width = Unit.Percentage(2)
            RadGrid1.MasterTableView.GetColumn("PR_KEY").HeaderStyle.Width = Unit.Point(0)
            RadGrid1.MasterTableView.GetColumn("Name").HeaderStyle.Width = Unit.Percentage(12)
            RadGrid1.MasterTableView.GetColumn("empnumber").HeaderStyle.Width = Unit.Percentage(10)
            RadGrid1.MasterTableView.GetColumn("Status").HeaderStyle.Width = Unit.Percentage(15)
            RadGrid1.MasterTableView.GetColumn("NetPay").HeaderStyle.Width = Unit.Percentage(6)
            RadGrid1.MasterTableView.GetColumn("keyid").HeaderStyle.Width = Unit.Point(0)
            RadGrid1.MasterTableView.GetColumn("hds").HeaderStyle.Width = Unit.Point(0)
  
            With objFilter
                If radioGD.Items(0).Selected = True Then
                    .mDeptKey = -1
                    .mGrpKey = -1
                    .mPayPeriod = -1
                ElseIf radioGD.Items(1).Selected = True Then
                    .mDeptKey = -1
                    .mGrpKey = cmbGroup.Items(cmbGroup.SelectedIndex).Value
                    .mPayPeriod = -1
                ElseIf radioGD.Items(2).Selected = True Then
                    .mDeptKey = cmbDepartment.Items(cmbDepartment.SelectedIndex).Value
                    .mGrpKey = -1
                    .mPayPeriod = -1
                ElseIf radioGD.Items(3).Selected = True Then
                    .mDeptKey = -1
                    .mGrpKey = -1
                    .mPayPeriod = cmbPayperiod.Items(cmbPayperiod.SelectedIndex).Value
                End If
                Dim TempDateString As String
                TempDateString = cmbPaydate.Items(cmbPaydate.SelectedIndex).Value
                If IsDate(TempDateString) Then
                    .mPayDate = TempDateString
                End If
                If cmbBankAC.SelectedIndex >= 0 Then
                    .mBankAc = cmbBankAC.Items(cmbBankAC.SelectedIndex).Value
                End If
            End With
  
            objDs = New DataSet
  
            If (objPayroll.GetPayCheckList(objDs, objFilter, excep, 1) = False) Then
                Throw New Exception(excep.ToString)
            End If
  
            objDv = Nothing
            If objDs.Tables(0).Rows.Count > 0 Then
                objDv = objDs.Tables(0).DefaultView
                RadGrid1.DataSource = objDv
            Else
                RadGrid1.DataSource = Nothing
            End If
  
              
        Catch ex As Exception
            DisplayError(ex)
        Finally
            If (Not objCombo Is Nothing) Then
                objCombo.Dispose()
                objCombo = Nothing
            End If
            If (Not objPayroll Is Nothing) Then
                objPayroll.Dispose()
                objPayroll = Nothing
            End If
        End Try
    End Sub
0
Tsvetoslav
Telerik team
answered on 12 Nov 2010, 01:14 PM
Hi Kiran,

In order for you to populate the grid with new data, you need to rebind it, calling its Rebind() method.

Regards,
Tsvetoslav
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
Asked by
Kiran
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Kiran
Top achievements
Rank 1
Share this question
or