GST Billing Software

header image

Load a Form conditionally with data loading

Erachana Line

6. How to load a Form conditionally with data loading?

There are 2 ways to load data conditionally,

1. Using Load Conditions by default, which are associated to form properties. You need to only write only the conditions in Properties Tab, Load Conditions section, under 'Condition1 and Condition2'. Here you are limited to write only 2 conditions.

Example - For Party Master Table, if Party Type = 1, then Party Master Form loads only Customers.

2. We can write a custom code for this, and we can change the default Load Functions. To do so, add an expression, and associate it to Form_Load Event. Example -

int cType = TypeConverter.ConvertToInt(this.Value); DataTable dt = (DataTable) (DataAdapter.Current.LoadData("select * from PartyMaster where (PartyType =" + cType + " or PartyType =3) Order by PartyName", "PartyMaster")); if(dt != null) { dgrData.DataSource = dt; }

Note : Table name should be same as in the Database, with case sensitivity. And you need to use DataAdapter Class (and not SQLInterpreter and ControlAdapter.Filter).