473,386 Members | 1,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How do I refresh DataView filter efficiently

The following code retrieves data into a dataset, and then creates a dataview
with a filter. This dataview is then attached to a combobox. When the
effective date changes, I would like to see the newly filtered data without
having to create a new dataview each time. Is that possible?
Also, do I need to attach the dataview to the combo box each time?

if (AgencyCounties == null || sPropertyState.Text != prevPropertyState)
{
AgencyCounties = Producer.GetAgencyCounties(Producer.AgencyId,
sPropertyState.Text,"11");

AgencyCounties.Tables["Table"].TableName = "AgencyCounty";
prevPropertyState = sPropertyState.Text;
}

sPropertyCountyCd.BeginUpdate();

DataView viewCounties = new DataView(AgencyCounties.Tables["AgencyCounty"]);

string Filter = "StartDt <= '" + sEffectiveDt.Text + "' AND (StopDt is Null
OR StopDt > '" + sEffectiveDt.Text + "')";

viewCounties.RowFilter = Filter;

sPropertyCountyCd.DisplayMember = "Name";
sPropertyCountyCd.ValueMember = "CountyCd";
sPropertyCountyCd.DataSource = viewCounties;
sPropertyCountyCd.EndUpdate();
Nov 17 '05 #1
3 11413
Vern,

You should be able to set the Filter of the view that the list is bound
to, and it should change the list automatically when the filter is set.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Vern" <Ve**@discussions.microsoft.com> wrote in message
news:F6**********************************@microsof t.com...
The following code retrieves data into a dataset, and then creates a
dataview
with a filter. This dataview is then attached to a combobox. When the
effective date changes, I would like to see the newly filtered data
without
having to create a new dataview each time. Is that possible?
Also, do I need to attach the dataview to the combo box each time?

if (AgencyCounties == null || sPropertyState.Text != prevPropertyState)
{
AgencyCounties = Producer.GetAgencyCounties(Producer.AgencyId,
sPropertyState.Text,"11");

AgencyCounties.Tables["Table"].TableName = "AgencyCounty";
prevPropertyState = sPropertyState.Text;
}

sPropertyCountyCd.BeginUpdate();

DataView viewCounties = new
DataView(AgencyCounties.Tables["AgencyCounty"]);

string Filter = "StartDt <= '" + sEffectiveDt.Text + "' AND (StopDt is
Null
OR StopDt > '" + sEffectiveDt.Text + "')";

viewCounties.RowFilter = Filter;

sPropertyCountyCd.DisplayMember = "Name";
sPropertyCountyCd.ValueMember = "CountyCd";
sPropertyCountyCd.DataSource = viewCounties;
sPropertyCountyCd.EndUpdate();

Nov 17 '05 #2
I changed it to this, and it doesn't change what the combobox is showing.
Debug shows it executing "viewCounties.RowFilter = Filter" but the drop down
list doesn't change. What am I doing wrong?

// Refresh the Dataset if the Property State changes
if (AgencyCounties == null || sPropertyState.Text != prevPropertyState)
{
AgencyCounties = Producer.GetAgencyCounties(Producer.AgencyId,
sPropertyState.Text,"11");
AgencyCounties.Tables["Table"].TableName = "AgencyCounty";
prevPropertyState = sPropertyState.Text;
}

if (viewCounties == null)
{
sPropertyCountyCd.BeginUpdate();
viewCounties = new DataView(AgencyCounties.Tables["AgencyCounty"]);
Filter = "StartDt <= '" + sEffectiveDt.Text + "' AND (StopDt is Null OR
StopDt > '" + sEffectiveDt.Text + "')";
viewCounties.RowFilter = Filter;
sPropertyCountyCd.DisplayMember = "Name";
sPropertyCountyCd.ValueMember = "CountyCd";
sPropertyCountyCd.DataSource = viewCounties;
sPropertyCountyCd.EndUpdate();
}
else
{
viewCounties.RowFilter = Filter;
}

"Nicholas Paldino [.NET/C# MVP]" wrote:
Vern,

You should be able to set the Filter of the view that the list is bound
to, and it should change the list automatically when the filter is set.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Vern" <Ve**@discussions.microsoft.com> wrote in message
news:F6**********************************@microsof t.com...
The following code retrieves data into a dataset, and then creates a
dataview
with a filter. This dataview is then attached to a combobox. When the
effective date changes, I would like to see the newly filtered data
without
having to create a new dataview each time. Is that possible?
Also, do I need to attach the dataview to the combo box each time?

if (AgencyCounties == null || sPropertyState.Text != prevPropertyState)
{
AgencyCounties = Producer.GetAgencyCounties(Producer.AgencyId,
sPropertyState.Text,"11");

AgencyCounties.Tables["Table"].TableName = "AgencyCounty";
prevPropertyState = sPropertyState.Text;
}

sPropertyCountyCd.BeginUpdate();

DataView viewCounties = new
DataView(AgencyCounties.Tables["AgencyCounty"]);

string Filter = "StartDt <= '" + sEffectiveDt.Text + "' AND (StopDt is
Null
OR StopDt > '" + sEffectiveDt.Text + "')";

viewCounties.RowFilter = Filter;

sPropertyCountyCd.DisplayMember = "Name";
sPropertyCountyCd.ValueMember = "CountyCd";
sPropertyCountyCd.DataSource = viewCounties;
sPropertyCountyCd.EndUpdate();


Nov 17 '05 #3
Never mind. I just realized my mistake. I wasn't changing the filter string.
The else should have been as follows:
else
{
Filter = "StartDt <= '" + sEffectiveDt.Text + "' AND (StopDt is Null OR
StopDt > '" + sEffectiveDt.Text + "')";
viewCounties.RowFilter = Filter;
}

"Vern" wrote:
I changed it to this, and it doesn't change what the combobox is showing.
Debug shows it executing "viewCounties.RowFilter = Filter" but the drop down
list doesn't change. What am I doing wrong?

// Refresh the Dataset if the Property State changes
if (AgencyCounties == null || sPropertyState.Text != prevPropertyState)
{
AgencyCounties = Producer.GetAgencyCounties(Producer.AgencyId,
sPropertyState.Text,"11");
AgencyCounties.Tables["Table"].TableName = "AgencyCounty";
prevPropertyState = sPropertyState.Text;
}

if (viewCounties == null)
{
sPropertyCountyCd.BeginUpdate();
viewCounties = new DataView(AgencyCounties.Tables["AgencyCounty"]);
Filter = "StartDt <= '" + sEffectiveDt.Text + "' AND (StopDt is Null OR
StopDt > '" + sEffectiveDt.Text + "')";
viewCounties.RowFilter = Filter;
sPropertyCountyCd.DisplayMember = "Name";
sPropertyCountyCd.ValueMember = "CountyCd";
sPropertyCountyCd.DataSource = viewCounties;
sPropertyCountyCd.EndUpdate();
}
else
{
viewCounties.RowFilter = Filter;
}

"Nicholas Paldino [.NET/C# MVP]" wrote:
Vern,

You should be able to set the Filter of the view that the list is bound
to, and it should change the list automatically when the filter is set.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Vern" <Ve**@discussions.microsoft.com> wrote in message
news:F6**********************************@microsof t.com...
The following code retrieves data into a dataset, and then creates a
dataview
with a filter. This dataview is then attached to a combobox. When the
effective date changes, I would like to see the newly filtered data
without
having to create a new dataview each time. Is that possible?
Also, do I need to attach the dataview to the combo box each time?

if (AgencyCounties == null || sPropertyState.Text != prevPropertyState)
{
AgencyCounties = Producer.GetAgencyCounties(Producer.AgencyId,
sPropertyState.Text,"11");

AgencyCounties.Tables["Table"].TableName = "AgencyCounty";
prevPropertyState = sPropertyState.Text;
}

sPropertyCountyCd.BeginUpdate();

DataView viewCounties = new
DataView(AgencyCounties.Tables["AgencyCounty"]);

string Filter = "StartDt <= '" + sEffectiveDt.Text + "' AND (StopDt is
Null
OR StopDt > '" + sEffectiveDt.Text + "')";

viewCounties.RowFilter = Filter;

sPropertyCountyCd.DisplayMember = "Name";
sPropertyCountyCd.ValueMember = "CountyCd";
sPropertyCountyCd.DataSource = viewCounties;
sPropertyCountyCd.EndUpdate();


Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: RPI_alum | last post by:
I've been experiencing some frustrating behavior that I believe may be a MS bug in the Framework. Has anyone else experienced this, know a better way to resolve it, or if it is an actual MS bug ...
1
by: werk | last post by:
For limiting access to the database to strictly necessary I try to filter the query by using DataView. Thw DataSet ds contains three columns (fields) : (LAND_ID, Landcode, Landnaam) and four...
13
by: Steve | last post by:
I have a form with a dataset and a datagrid. I created a dataview on this dataset. When the user modifies the datagrid, I look up this record in the dataview to make sure it is unique. Here is...
5
by: David Wender | last post by:
I want to create a dataview with a sort on multiple columns. However, when I use FindRows, I only want to search some of the columns, not all. Is this possible? I have not been able to make it...
8
by: KC | last post by:
For a DataView.Rowfilter can I use more than one expression? I want to filter out two different things. For example can I take: dv.RowFilter = "MTX <> 'Customer Forcast'" and ...
17
by: A_PK | last post by:
I have problem databinding the DataGrid with DataView/DataSet after the filter... I create the following proceudre in order for user to filter as many as they want, but the following code is only...
4
by: James | last post by:
Basically I have a DataGrid that I'm binding to the results of a stored procedure call. The recordset is fairly small. Initially I'm creating a DataSet from the results and binding it. There's a...
1
by: AlexW | last post by:
Hi I am in the process of developing an inventory application in visual basic. I keep coming up against a problem with using the dataview.rowfilter property. Basically what happens is this: -a...
5
by: AlexW | last post by:
Hi I am in the process of developing an inventory application in visual basic. I keep coming up against a problem with using the dataview.rowfilter property. Basically what happens is this: -a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.