Click here to Skip to main content
15,886,823 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i am new in c# sql,i want to show total number records that has been entered in to the database.
here is the code
ASP.NET
<label class="col-sm-3">
                    Count:
                </label>
                <div class="col-sm-2">
                    <asp:TextBox runat="server" ID="txtCount" AutoPostBack="true"></asp:TextBox>
                    <asp:Button runat="server" ID="check" OnClick="check_Click" Text="Check"  />


                </div>

Codebehind is
C#
protected void check_Click(object sender, EventArgs e)
       {

               var employee = _service.GetAllEmployee();

               txtCount.Text = employee.Count().ToString();

       }
Posted
Comments
Afzaal Ahmad Zeeshan 11-Nov-14 1:52am    
And how does it not work?
Mathew Soji 11-Nov-14 2:00am    
Did you debug the code ? Check whether the code flow reaches the click event handler?
If code flow reaches click handler ,check what is the value returned by _service.GetAllEmployee();
Afzaal Ahmad Zeeshan 11-Nov-14 3:06am    
Sir, you needed to post this comment to his post not my comment. :-)

Thanks.
Mathew Soji 11-Nov-14 3:26am    
Yup , Got it.
Sajid227 11-Nov-14 2:06am    
i debug it now after post back it return total no of records.thanx to all guys

1 solution

Did you debug the code ? Check whether the code flow reaches the click event handler?
If code flow reaches click handler ,check what is the value returned by _service.GetAllEmployee();
 
Share this answer
 
Comments
Sajid227 13-Nov-14 5:16am    
it return null
Mathew Soji 13-Nov-14 5:25am    
Then debug your service. Check whether the service is up and running ?

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