Hi Loic,
Thanks for providing the simple example!
It does work as is and works when I change the rbtnUpdateSuppCodes_Click to bind the DataSource of rcbbSupplierCode to an ArrayList.
But it does not work when I pass rcbbSupplierCode by reference to a function in a .vb file in App_Code folder.
Here is a copy of rbtnUpdateSuppCodes_Click :
Protected
Sub
rbtnUpdateSuppCodes_Click(sender
As
Object
, e
As
EventArgs)
Dim
ComboboxList
As
New
ArrayList()
Dim
strFilename
As
String
=
""
, strFieldName
As
String
=
""
Dim
sql
As
String
=
""
System.Threading.Thread.Sleep(5000)
rcbbSupplierCode.Items.Clear()
ComboboxList.Add(
"ALL"
)
For
i
As
Integer
= 1
To
100
'rcbbSupplierCode.Items.Add("Item " + i.ToString("00"))
ComboboxList.Add(
"Item "
+ i.ToString(
"00"
))
Next
'rcbbSupplierCode.DataSource = ComboboxList
'rcbbSupplierCode.DataBind()
strFilename =
"RSDCContainerScrapppedSuppCodes.txt"
sql =
"SELECT DISTINCT SUPPLIER_CODE FROM VIEW_PLEX_CONT_SCRAPPED_RPT WHERE NOT SUPPLIER_CODE IS NULL ORDER BY SUPPLIER_CODE ASC"
strFieldName =
"SUPPLIER_CODE"
rcbbSupplierCode.DataSource =
Nothing
UserFunctions.UpdateRadCombobox(strFilename, sql, strFieldName, rcbbSupplierCode,
"S01"
,
True
)
End
Sub
Here is the code for UpdateRadCombobox procedure in the .vb file in App_Code folder:
Public
Shared
Sub
UpdateRadCombobox(
ByVal
sFile
As
String
,
ByVal
sSQL
As
String
,
ByVal
sTableField
As
String
,
ByRef
RadComboboxObj1
As
RadComboBox,
ByVal
sDBServer
As
String
,
Optional
ByVal
bAddALL
As
Boolean
=
False
)
Dim
dsList
As
DataSet
Dim
strFilePath
As
String
Dim
SWFileWrite
As
System.IO.StreamWriter
Dim
ComboboxList
As
New
ArrayList()
dsList = DataSetConfiguration.OracleDataSet(sSQL, sDBServer)
If
RadComboboxObj1.Items.Count > 0
Then
RadComboboxObj1.Items.Clear()
End
If
If
bAddALL
Then
ComboboxList.Add(
"ALL"
)
End
If
If
dsList.Tables(0).Rows.Count > 0
Then
strFilePath = HttpContext.Current.Server.MapPath(sFile)
If
File.Exists(strFilePath)
Then
SWFileWrite = File.CreateText(strFilePath)
For
Each
iRow
In
dsList.Tables(0).Rows
SWFileWrite.WriteLine(iRow(sTableField))
ComboboxList.Add(iRow(sTableField))
Next
SWFileWrite.Close()
End
If
End
If
RadComboboxObj1.DataSource = ComboboxList
RadComboboxObj1.DataBind()
End
Sub
Any ideas?
Sincerely,
Keith Jackson