I have a CheckBoxList
like this. (There are customer name)
These are customer name and every customer has a customer number (Unique
-- Primary Key
)
Table: S_TEKLIF
MUS_K_ISIM
represent Customer Name
HESAP_NO
represent Customer Number
I have a Send Button
and Gridview
.
When i click the Send Button,
In my Gridview
, I just want run this SQL
;
SELECT A.HESAP_NO, A.TEKLIF_NO1 || '/' || A.TEKLIF_NO2 AS TEKLIF, A.MUS_K_ISIM,
B.MARKA, C.SASI_NO, C.SASI_DURUM, D.TAS_MAR, RISK_SASI(A.TEKLIF_NO1, A.TEKLIF_NO2, C.SASI_NO) AS RISK,
MV_SASI(A.TEKLIF_NO1, A.TEKLIF_NO2, C.SASI_NO, SYSDATE) 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 A.HESAP_NO IN (
But as you can see bottom of th SQL
, I just want to show "Which customers i selected in CheckBoxList" in my Gridview.
How can i do that?
What should be in my Send_Click()
function and in my SQL
?
Best Regards, Soner
I am making statment in plain english format
in your button click event add the code below
protected void mybutton_click()
{
StringBuilder sb = new StringBuilder();
foreach(ListItem item in CustomerListBox.Items)
{
If(item.selected)
{
sb.Append(item.SelectedValue+",");
}
}
FillGridview(sb);
}
private void FillGridview(StringBuilder sb)
{
string s = sb.tostring().remove().lastindexof(",");
//pass this string as param and set it your where condition.
// Get the datatble or collection and bind grid.
}
Select your desired columsn to display
From Your Tables (put joins if required)
Where CustomerNumber IN (@CommaSeparatedAboveString_s);
Itrate for each item in your checkbox list and check if the item is checked, if yes then get the customer id against that item (which you might be placing in value attribute of item). Prepare a comma separated list of those customer ids and passed into the IN clause of your SQL. So it would be something like below.
SELECT A.HESAP_NO, A.TEKLIF_NO1 || '/' || A.TEKLIF_NO2 AS TEKLIF, A.MUS_K_ISIM,
B.MARKA, C.SASI_NO, C.SASI_DURUM, D.TAS_MAR, RISK_SASI(A.TEKLIF_NO1, A.TEKLIF_NO2, C.SASI_NO) AS RISK,
MV_SASI(A.TEKLIF_NO1, A.TEKLIF_NO2, C.SASI_NO, SYSDATE) 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 A.HESAP_NO IN (12,14,13,18,26)
精彩评论