GST Billing Software

header image

Filter a Control using another Control

Erachana Line

35. How to filter a control using another control (cascading)?

Depending upon the requirement, we need to filter a control, depending upon changes in another control. For instance, Country-State-Place filter.

if (txt_PlaceId.DataSource != null && txt_State.DataSource != null && txt_State.SelectedIndex >= 0)

{

lbl_State_Code.Text = "StateCode: " + TypeConverter.ConvertToString(((DataTable)txt_State.DataSource).Rows[txt_State.SelectedIndex]["statecode"]);

ControlAdapter.Filter(txt_PlaceId, "StateId=" + txt_State.SelectedValue, fieldSqls);

txt_PlaceId.SelectedIndex = -1;

}

else

{

if (txt_PlaceId.DataSource != null)

txt_PlaceId.SelectedIndex = -1;

lbl_State_Code.Text = "";

}