We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

how to modify the existing column type which is loaded from Datasets(through SQLDataAdapter)

  Public constring As String = AlgoMdConnectionString       
 Try
            Using con As New SqlConnection(constring)
                Using cmd As New SqlCommand("SELECT
TAP_BillDate AS [Bill Date],
'False' AS [isClosed],
TAP_Payable AS [Balance],
'' AS [Payment]
from Tbl_AccPending 
", con)
                    cmd.CommandType = CommandType.Text
                    Using sda As New SqlDataAdapter(cmd)
                        Using ds As New DataSet()
                            sda.Fill(ds)
                               SfDataGrid1.DataSource = ds.Tables(0)
                                'SfDataGrid1.Columns.Add(New GridCheckBoxColumn() With {.MappingName = "isClosed", .HeaderText = "isClosed", .CheckBoxSize = New Size(15, 15), .TrueValue = "True", .FalseValue = "False"})

                                    
                        End Using
                    End Using
                End Using
            End Using
        Catch ex As Exception
            IO.File.AppendAllText(appDataPath & "\Log.txt", String.Format("{0}{1}", Environment.NewLine, ex.ToString()))
       End Try

on the above SQL Commands i have to modify 'isClosed' column as CheckBoxColumn .. i try SfDataGrid1.Columns.Add(New GridCheckBoxColumn() , but it creating new checkbox column at the end of all columns.. But i needs to modify the existing column loads from dataset at its same position.. if u have any other way to solve this, please let me know..

--regards
Sulthan

1 Reply

FP Farjana Parveen Ayubb Syncfusion Team January 20, 2020 09:01 AM UTC

Hi Sulthan, 
 
Thank you for using Syncfusion controls. 
 
You can modify the existing column type in SfDataGrid.AutoGeneratingColumns event. Please refer the below code example, 
 
AddHandler sfDataGrid.AutoGeneratingColumn, AddressOf SfDataGrid_AutoGeneratingColumn 
sfDataGrid.DataSource = employeeCollection 
 
Private Sub SfDataGrid_AutoGeneratingColumn(ByVal sender As Object, ByVal e As AutoGeneratingColumnArgs) 
       If e.Column.MappingName = "IsClosed" Then 
              e.Column = New GridCheckBoxColumn() With {.MappingName = "IsClosed", .HeaderText = "Is Closed"} 
       End If 
End Sub 
 
 
 
Please let us know if you need any further details on this. 
 
Regards,
Farjana Parveen A
 
 


Loader.
Live Chat Icon For mobile
Up arrow icon