the first time I load the datagrid with a dataset it works fine.
I then do a new query reload the dataset with new data which fills fine.
But the datagrid ends up displaying nothing.
Just the column headings appear with a blank row.
What am I missing
Thanks
Below is the code:
PrivateSub getListGrid()
Dim ff As clsFTP
Dim myFiles() AsString
Dim myflg AsBoolean = False
Dim myret AsBoolean
'used for all the form Dim ds As New DataSet
Dim dtable AsNew DataTable("Files")
Dim row As DataRow
' ff = New clsFTP(myRemoteHost, _
' myRemotePath, _
' myRemoteUser, _
' myRemotePassword, _
' myRemotePort)
ff = New clsFTP(myRemoteHost, _
".", _
myRemoteUser, _
myRemotePassword, _
myRemotePort)
'Try to log on to the FTP server.
ds.Clear()
Try
ds.Tables.Remove("Files")
Catch ex As Exception
EndTry
With dtable.Columns
.Add("Count", GetType(System.Int32))
.Add("FileName", GetType(System.String))
.Add("DownLoad", GetType(System.Boolean))
EndWith
ds.Tables.Add(dtable)
If (ff.Login() = True) Then
myret = ff.ChangeDirectory(myRemotePath)
If myret = FalseThen MsgBox("Could not reach FTP Site - restart application")
ff.SetBinaryMode(False)
myFiles = ff.GetFileList(" ")
Dim myFile AsString
If myFiles.Length > 0 Then
Dim cnt AsInteger
cnt = 0
ForEach myFile In myFiles
cnt += 1
row = ds.Tables("Files").NewRow
row(0) = cnt
row(1) = CStr(myFile)
row(2) = False
ds.Tables("Files").Rows.Add(row)
ds.Tables("Files").AcceptChanges()
' MsgBox(myFile)
Next
Try
ff.CloseConnection()
Catch
Finally
ff = Nothing
EndTry
EndIf
EndIf
dg.TableStyles.Clear()
dg.DataSource = Nothing
dg.SetDataBinding(ds, "Files")
Dim styles AsNew DataGridTableStyle
styles.MappingName = "File"
Dim colCount AsNew DataGridTextBoxColumn
colCount.MappingName = "COUNT"
colCount.HeaderText = "Count"
colCount.Width = 40
styles.GridColumnStyles.Add(colCount)
Dim colF AsNew DataGridTextBoxColumn
colF.MappingName = "FILENAMES"
colF.HeaderText = "FileName"
colF.Width = 200
styles.GridColumnStyles.Add(colF)
Dim colDownLoad AsNew DataGridBoolColumn
colDownLoad.MappingName = "DownLoad"
colDownLoad.Width = 70
colDownLoad.HeaderText = "DownLoad"
styles.GridColumnStyles.Add(colDownLoad)
dg.TableStyles.Add(styles)
dg.Visible = True
ff = Nothing
EndSub
I then do a new query reload the dataset with new data which fills fine.
But the datagrid ends up displaying nothing.
Just the column headings appear with a blank row.
What am I missing
Thanks
Below is the code:
PrivateSub getListGrid()
Dim ff As clsFTP
Dim myFiles() AsString
Dim myflg AsBoolean = False
Dim myret AsBoolean
'used for all the form Dim ds As New DataSet
Dim dtable AsNew DataTable("Files")
Dim row As DataRow
' ff = New clsFTP(myRemoteHost, _
' myRemotePath, _
' myRemoteUser, _
' myRemotePassword, _
' myRemotePort)
ff = New clsFTP(myRemoteHost, _
".", _
myRemoteUser, _
myRemotePassword, _
myRemotePort)
'Try to log on to the FTP server.
ds.Clear()
Try
ds.Tables.Remove("Files")
Catch ex As Exception
EndTry
With dtable.Columns
.Add("Count", GetType(System.Int32))
.Add("FileName", GetType(System.String))
.Add("DownLoad", GetType(System.Boolean))
EndWith
ds.Tables.Add(dtable)
If (ff.Login() = True) Then
myret = ff.ChangeDirectory(myRemotePath)
If myret = FalseThen MsgBox("Could not reach FTP Site - restart application")
ff.SetBinaryMode(False)
myFiles = ff.GetFileList(" ")
Dim myFile AsString
If myFiles.Length > 0 Then
Dim cnt AsInteger
cnt = 0
ForEach myFile In myFiles
cnt += 1
row = ds.Tables("Files").NewRow
row(0) = cnt
row(1) = CStr(myFile)
row(2) = False
ds.Tables("Files").Rows.Add(row)
ds.Tables("Files").AcceptChanges()
' MsgBox(myFile)
Next
Try
ff.CloseConnection()
Catch
Finally
ff = Nothing
EndTry
EndIf
EndIf
dg.TableStyles.Clear()
dg.DataSource = Nothing
dg.SetDataBinding(ds, "Files")
Dim styles AsNew DataGridTableStyle
styles.MappingName = "File"
Dim colCount AsNew DataGridTextBoxColumn
colCount.MappingName = "COUNT"
colCount.HeaderText = "Count"
colCount.Width = 40
styles.GridColumnStyles.Add(colCount)
Dim colF AsNew DataGridTextBoxColumn
colF.MappingName = "FILENAMES"
colF.HeaderText = "FileName"
colF.Width = 200
styles.GridColumnStyles.Add(colF)
Dim colDownLoad AsNew DataGridBoolColumn
colDownLoad.MappingName = "DownLoad"
colDownLoad.Width = 70
colDownLoad.HeaderText = "DownLoad"
styles.GridColumnStyles.Add(colDownLoad)
dg.TableStyles.Add(styles)
dg.Visible = True
ff = Nothing
EndSub