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]
> - (E-Mail Removed)
>
> "Vern" <(E-Mail Removed)> wrote in message
> news:F6D989D0-85F1-4315-BD9B-(E-Mail Removed)...
> > 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();
>
>
>