Records not updating

  • Thread starter Thread starter Monty
  • Start date Start date
M

Monty

Hi there, I have a simple medical database with patient records. I use:
TotalRecords.Text = DetailsViewMain.DataItemCount & " records" to reflect
the number of patients in the db.
I then filter the records per person and update the count with the same
code. My problem is that the actual number of records is always off by one
update. That is to say that initially it reads correctly say 25 records.
Then I filter for person1 which has 3 records. The TotalRecords will read
25 the first time, then I filter for person2, which should read 4 but it
reads 3. Very strange! Any help with this?
Is there a way to cause an update/postback whatever to get the correct
number consistantly?

Thank you, Mark
 
It appears that you are reading the DataItemCount property before the
filtering takes effect.

What do you use for data source, and what do you do to filter it?
 
Hi, and thanks in advance.

* What do you use for data source, and what do you do to filter it?

Protected Sub ListBoxSelectRCP_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles
ListBoxSelectRCP.SelectedIndexChanged

If ListBoxSelectRCP.SelectedIndex + 1 = 1 Then
DetailsViewMain.DataSourceID = "roomFind1"
ListBoxSelectPatient.DataSourceID = "Patientfind1"
ListBoxSelectRoom.DataSourceID = "RoomFind1"
End If

If ListBoxSelectRCP.SelectedIndex + 1 = 2 Then
DetailsViewMain.DataSourceID = "roomFind2"
ListBoxSelectPatient.DataSourceID = "Patientfind2"
ListBoxSelectRoom.DataSourceID = "RoomFind2"
End If

TotalRecords.Text = DetailsViewMain.DataItemCount & " records"

End sub
 
Setting the DataSourceID property doesn't perform a DataBind, it only
set the RequiresDataBinding property. The data binding is done at some
later stage, probably when the control is going to be rendered and
detects that it needs data binding.

You either have to call DataBind yourself before getting DataItemCount,
or get it after the data binding occurs.
 
Back
Top