Soner Gonul

Soner Gonul

  • NA
  • 8
  • 9.3k

CheckBox adding Parameter with SQL IN to Gridview

Mar 23 2011 2:57 AM

Hello

I have a CheckBoxList that is showing all S_TEKLIF table MUS_K_ISIM column.

SELECT  DISTINCT MUS_K_ISIM
FROM S_TEKLIF A
ORDER BY
MUS_K_ISIM

My S_TEKLIF table has two columns.

HESAP_NO-->Primary Key

MUS_K_ISIM--> Every MUS_K_ISIM has a unique HESAP_NO.

I have an SQL like this for my Gridview Source;


strQuery = @"SELECT A.HESAP_NO, A.TEKLIF_NO1 || '/' || A.TEKLIF_NO2 AS TEKLIF, A.MUS_K_ISIM AS MUSTERI,
                    B.MARKA, C.SASI_NO, C.SASI_DURUM, D.TAS_MAR, NVL(RISK_SASI(A.TEKLIF_NO1, A.TEKLIF_NO2, C.URUN_SIRA_NO, C.SIRA_NO),0) AS RISK,
                    NVL(MV_SASI(A.TEKLIF_NO1, A.TEKLIF_NO2, C.URUN_SIRA_NO, C.SIRA_NO, SYSDATE),0) AS MV
                    FROM S_TEKLIF A,  S_URUN B, S_URUN_DETAY C, KOC_KTMAR_PR D
                    WHERE A.TEKLIF_NO1 || A.TEKLIF_NO2 = B.TEKLIF_NO1 || B.TEKLIF_NO2
                    AND A.TEKLIF_NO1 || A.TEKLIF_NO2 = C.TEKLIF_NO1 || C.TEKLIF_NO2
                    AND B.SIRA_NO = C.URUN_SIRA_NO
                    AND B.DISTRIBUTOR = D.DIST_KOD
                    AND B.MARKA = D.MARKA_KOD
                    AND B.URUN_KOD = D.TAS_KOD ";


And i want programaticly, adding my query, which i selected in CheckBoxList.

I try this code;


ArrayList values = new ArrayList();
        for (int i = 0; i < CheckBoxList1.Items.Count; i++ )
        {
            if (CheckBoxList1.Items[i].Selected)
            {
                values.Add(CheckBoxList1.Items[i].Value);
            }
        }

        strQuery = strQuery + " AND A.HESAP_NO IN (SELECT A.HESAP_NO FROM S_TEKLIF A WHERE A.MUS_K_ISIM IN (" + values + "))";


But it doesn't work.

How can i do that?


Attachment: progs.rar

Answers (3)