Click here to Skip to main content
15,891,864 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Everyone

In my datagridview Gender is the one column in this column Male and Female are two value i want to take total count of Male and Female


Like
<br />
           Gender<br />
<br />
            Male<br />
            Male<br />
            Female<br />
            Female<br />
            Male<br />
            Female<br />
            Male<br />
            Male<br />
            Female<br />

i want like this

here is count of Male=5

And Female=4


Please Help me.
Posted
Comments
Richard MacCutchan 18-Oct-13 7:12am    
Loop through the rows counting the values in that column.
basurajkumbhar 18-Oct-13 7:21am    
How i am not getting any way to get count.
Can you please explain.
Sir.

Thank You,,,,
Richard MacCutchan 18-Oct-13 7:46am    
Read the documentation as mentioned in my suggested solution below.
Nelek 18-Oct-13 7:40am    

See the documentation[^] for RowCount and Rows properties.
 
Share this answer
 
VB
Dim ab As String
                    ab = dt.Rows(i)("Gender").ToString()
                    If ab = "Male" Then

                        txtfemale.Text = Integer.Parse(txtfemale.Text) + 1
                    ElseIf ab = "Female" Then
                        txtmale.Text = Integer.Parse(txtmale.Text) + 1
                    End If
                Next
                txttotal.Text = Integer.Parse(txtfemale.Text) + Integer.Parse(txtmale.Text)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900