john kanyora

john kanyora

  • 1.6k
  • 242
  • 16k

how to filter items from a selected dropdown list

Nov 6 2017 4:11 AM
Hi, am trying to filter items from a dropdownlist..i have written a select SQL statement in the xml table..below is the respective codes..the name of my filter is TreatmentGroup

the xml table with select statement code



<predefined>
<DetailFilters>
<FilterInfo Name="CompanyID" DataType="xs:string" Kind="Session"/>
<FilterInfo Name="BranchID" DataType="xs:string" Kind="Session"/>
<FilterInfo Name="DepartmentID" DataType="xs:string" Kind="Session"/>
<FilterInfo Name="MedicalSchemeID" DataType="xs:string" Kind="Form"/>
<FilterInfo Name="TreatmentGroup" DataType="xs:string" Kind="Form"/>
</DetailFilters>
<DetailSelectStatement xsi:type="QLiteralExpr">
SELECT
TreatmentItems.TreatmentGroup As TreatmentGroup,
MedicalSchemeDetail.*
FROM
MedicalSchemeDetail JOIN TreatmentItems ON
MedicalSchemeDetail.CompanyID = TreatmentItems.CompanyID AND
MedicalSchemeDetail.BranchID = TreatmentItems.BranchID AND
MedicalSchemeDetail.DepartmentID = TreatmentItems.DepartmentID AND
MedicalSchemeDetail.ItemID = TreatmentItems.TreatmentID
WHERE
TreatmentGroup=@TreatmentGroup
AND MedicalSchemeDetail.CompanyID = @CompanyID
AND MedicalSchemeDetail.BranchID = @BranchID
AND MedicalSchemeDetail.DepartmentID = @DepartmentID
AND MedicalSchemeDetail.MedicalSchemeID = @MedicalSchemeID
AND IsNull(MedicalSchemeDetail.Excluded,0) = 0
</DetailSelectStatement>

below here is the aspx code with the dropdown list

<asp:Label runat="server" ID="label" SkinID="groupCaptionSkin" ForeColor="Navy" Font-Names="Tahoma" Font-Size="Small" Text="TreatmentGroup" />
<asp:DropDownList ID="ddlItemGroup" OnSelectedIndexChanged= "ddlPeriodStamp_SelectedIndexChanged" runat ="server" AutoPostBack = "True">
<asp:ListItem Value="" Enabled="false"></asp:ListItem>
<asp:ListItem Value="ALL">ALL</asp:ListItem>
<asp:ListItem Value="Lab Test"> Lab Test</asp:ListItem>
<asp:ListItem Value="RADIOLOGY TEST">RADIOLOGY</asp:ListItem>
<asp:ListItem Value="NURSING">NURSING</asp:ListItem>
<asp:ListItem Value="Prescription">Prescription</asp:ListItem>
<asp:ListItem Value="VACCINES">VACCINES</asp:ListItem>
</asp:DropDownList>

this is the code behind with the filter

protected void ddlPeriodStamp_SelectedIndexChanged(object sender, System.EventArgs e)
{

DropDownList ddlItemGroup = (DropDownList)sender;

if (ddlItemGroup.SelectedValue != null)
ApplyGridFilter();

}

protected void ApplyGridFilter()
{

DBDataSource1.State.BusinessObject.DataPump.FormFilters.Clear();
DBDataSource1.State.BusinessObject.DataPump.FormFilters.Add("TreatmentGroup", TreatmentGroup);
DBDataSource1.State.BusinessObject.Fill(null);
MedicalSchemeDetailGrid.DataBind();
}

kindly help me

Answers (2)