I 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>
<predefined>
This 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>
</asp:Label>
That´s 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();
}
Your function ApplyGridFilter
is called after the user selects an item in the list. I suggest you to bind the DropDownList
from the code behind if you want to apply filters on the list you want to display, in PageLoad
for example.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.