Click here to Skip to main content
16,006,475 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a table with 3 columns. It contains numbers of rows. The value of last column is taken from second column which contains a Pair of possible values. I want to populate the third column with a combobox containing the value pair from second column. This value pair will be different for different column. I managed to write a query but it populates the same value list for all the rows.

table structure

PS_CODE        PS_PARAM    PS_VALUE
  A               Y;N          Y
  B               0;1          1


When this value populating on grid some time I want to change the value of Y to N or 1 to 0, then this PS_PARAM value should be shown on a combobox to select.

this is my code


For Each drow As DataRow In dSetChangeStatus.SM_POS_SETUP.Rows

Dim strValueList As String = "Select PS_PARAM FROM SM_POS_SETUP Where PS_CODE = '" & drow("PS_CODE") & "'"

Dim psValues As System.Data.SqlClient.SqlDataAdapter = New System.Data.SqlClient.SqlDataAdapter(strValueList, ConPOS)

Dim ds As DataSet = New System.Data.DataSet()

psValues.Fill(ds, "PS_PARAM")

Dim arrVal() As String = Split(drow("PS_PARAM"), ";")

Dim Column As Janus.Windows.GridEX.GridEXColumn = gridEXSetUp.RootTable.Columns("PS_VALUE")

Column.HasValueList = True

Dim valueList As Janus.Windows.GridEX.GridEXValueListItemCollection = Column.ValueList

valueList.PopulateValueList(ds.Tables("PS_PARAM").DefaultView, "PS_PARAM")

Column.EditType = Janus.Windows.GridEX.EditType.Combo


Next
Posted
Updated 1-Nov-10 0:06am
v2

1 solution

If PS_PARAM has always 3 signs and the second one is always ";", try to ask your database in this way:
SQL
SELECT SUBSTRING([PS_PARAM],1,1) AS PS_VALUES
  FROM [ERK].[dbo].[SM_POS_SETUP]
WHERE PS_CODE = 'A'
UNION ALL
SELECT SUBSTRING([PS_PARAM],3,1) AS PS_VALUES
  FROM [ERK].[dbo].[SM_POS_SETUP]
WHERE PS_CODE = 'A'

which SUBSTRING() function returns part of string.
You should see results (2 rows):
Y
N


I have never used control: Janus.Windows.GridEX, so i can't help you more.
I think, you should load this data to datatable (not dataset) and populate it with column, but first you should change this part of code:
VB
Column.EditType = Janus.Windows.GridEX.EditType.Combo
valueList.PopulateValueList(ds.Tables("PS_PARAM").DefaultView, "PS_PARAM")
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900