Hi,
In my proj i need to populate a gridview based on the selected value. I have abt 5 to 6 fields for searching including dropdown list and textboxes. Dropdown list is for country, region etc.. and the textboxes are for from_date and to_date. i'm using ms-access DB. so when i write the coding, it works fine if coding for all the other fields are written(except dates) or else only for dates alone.. but wen i combine these two the prob starts.. Also at the same time, if user does not enter the date but selects the remaining fields, it shows no records even if ther are some...
Now this s wat i want exactly::
Initially all the records will be displayed...
Then based on dropdown selection the reults in the grid should change...
Some things to note:
1.DDL may be with default value "Any" and dates may/may not be specified
2.DDL can be selected with any value and dates may/may not be specified
I ll post a part of the coding... so it helps better...
<asp:AccessDataSource ID="AccessDataSource1" runat="server"
DataFile="~/smsdb.accdb"
SelectCommand="SELECT * FROM [smsMessage]" FilterExpression="Partner like '{0}%' AND Country like '{1}%' AND Region like '{2}%' AND MessageDirection like '{3}%'">
<FilterParameters>
<asp:ControlParameter ControlID="ddlPartner" Name="Partner" PropertyName="SelectedValue"
Type="String" />
<asp:ControlParameter ControlID="ddlCountry" Name="Country" PropertyName="SelectedValue"
Type="String" />
<asp:ControlParameter ControlID="ddlRegion" Name="Region"
PropertyName="SelectedValue" Type="String" />
<asp:ControlParameter ControlID="ddlMsgDirection" Name="MessageDirection" PropertyName="SelectedValue"
Type="String" />
</FilterParameters>
</asp:AccessDataSource>
<asp:AccessDataSource ID="AccessDataSource2" runat="server"
DataFile="~/smsdb.accdb"
SelectCommand="SELECT DISTINCT [Country] FROM [smsMessage]">
</asp:AccessDataSource>
<asp:AccessDataSource ID="AccessDataSource3" runat="server"
DataFile="~/smsdb.accdb"
SelectCommand="SELECT DISTINCT [Region] FROM [smsMessage]">
</asp:AccessDataSource>
<asp:AccessDataSource ID="AccessDataSource4" runat="server"
DataFile="~/smsdb.accdb"
SelectCommand="SELECT DISTINCT [Partner] FROM [smsMessage]">
</asp:AccessDataSource>
<asp:AccessDataSource ID="AccessDataSource5" runat="server"
DataFile="~/smsdb.accdb"
SelectCommand="SELECT DISTINCT [MessageDirection] FROM [smsMessage]">
</asp:AccessDataSource>
So here each of the datasource selects the distinct fields.. and this works correct without dates,..
Someone pls help me with using dates... Or a new approach could be helpful...
Thanks...:-)