Monday, March 12, 2012

problem dynamicly populating a checkboxlist from a query

I have the follow, i get the right amout of checkboxes but they all have the same value(System.Data.Common.DbDataRecord)

Dim objconnAsNew SqlConnection(connstring_MPR)Dim objcmdAs SqlCommand =New SqlCommand("SELECT [Parts Master Table].COMMD_CODE as comcode FROM [Parts Master Table] INNER JOIN [Warehouse balance table] ON [Parts Master Table].PART_NUMBER = [Warehouse balance table].PART INNER JOIN POREPORT ON [Parts Master Table].PART_NUMBER = POREPORT.[Part Number] INNER JOIN [DEMAND TABLE] ON [Parts Master Table].PART_NUMBER = [DEMAND TABLE].PART WHERE POREPORT.[PO Bal] > 0 OR [DEMAND TABLE].QTY > 0 or [Warehouse balance table].ONHAND > 0 and [Parts Master Table].M_B = 1 AND [Warehouse balance table].WHSE = 'sgr' AND ([Parts Master Table].FAMILY NOT LIKE 'lam%' or [Parts Master Table].FAMILY NOT IN ('ULTCH', 'REMOT', 'MKSIN')) GROUP BY [Parts Master Table].COMMD_CODE ORDER BY [Parts Master Table].COMMD_CODE", objconn)

objconn.Open()

chkComCode.DataSource = objcmd.ExecuteReader(CommandBehavior.CloseConnection)

chkComCode.DataBind()

objconn.Close()

First thing is, run your query in Query Analyzer and see it returns the same value(comcode) for each row. And secondly set DataText field and DataValue field. [even though it is not necessary for your query]

chkComCode.DataTextField="comcode"
chkComCode.DataValueField="comcode"

|||

yep i had to go into source and set the textfield/value field to = comcode

No comments:

Post a Comment