Question:
Folks,
This is what I am trying to do:
I am trying to create a summary table where the table will display the total number of test cases in the DB, total number of passing test cases etc. The number for total number of test cases, passing test cases etc is obtained by doing a query and using COUNT function within the query. I am displaying the data in detailview control. The question I have is how do I do dynamic calculation and enter the result in one of the detailview control. For example, I want to take the total number of test cases that were found in DB and subtract passing test cases and enter the result in the detailview control. I don't have to use the detailview control. I can use other controls but I do want the table to look nice and consistence.
Any help is appreciated.
Answer1:
Hi skantesaria,
If you want to calculate result by users, you can add a Button or LinkButton in DetailsView and add OnClick event for this button. In this onclick event you can get the total number and passing test number from DetailsView control, and then make calculation to enter result into a given Label or TextBox in DetailsView.
If you want to calculate result while DetailsView Loaded, you can do the above calculation in OnDataBound event of DetailsView control.
Using FindControl() to access control in DetailsView.
Thanks,
Answer2:
Thanks for the info Qin Dian Tang. I do understand the logic that you presented. The next question I have is how do implement this logic that you presented.
I have a Four details view controls:
- AllTC
-PassingTC
-FailingTC
-PendingTC (This is the one I am trying to calculate)
What I did is that for PendingTC, i created a databound event which opened up the code behind file that I could edit. This is what the code behind file looks like
Protected Sub CalculatePendingTC(ByVal sender As Object, ByVal e As System.EventArgs) Handles dvPending.DataBound
dvPending = dvallTC.SelectedValue - dvpass.SelectedValue - dvFail.SelectedValue
End Sub
However there are two things that are happening:
First is that the detailsview control is not showing up on the webpage when I run it. I am assuming that this is because it is not assigned to any sqlsource. Second is that I have a breakpoint in the code behind file and it never reaches the breakpoint.
Any help will be appreciated. I am fairly new at this stuff.
Thanks
Answer3:
Hi skantesaria,
Of course there is no databinding in this detailsview, so databound event will be never fired. Changing to OnLoad event to see if it works fine.
Why not show these infomation in one detailsview except that you have many items in each detailsview.
Thanks,