单击按钮时,如何在txtbox中显示总记录数 [英] How do I show total record no in a txtbox when button is clicked

查看:112
本文介绍了单击按钮时,如何在txtbox中显示总记录数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是c#sql的新手,我想显示已经输入数据库的总数记录。

这里是代码

 <   label    < span class =code-attribute> class   =  col-sm-3 >  
计数:
< / label >
< div class = col-sm-2 >
< asp:TextBox runat = server ID = txtCount AutoPostBack = true > < / asp:TextBox >
< asp:按钮 runat = 服务器 ID = 检查 OnClick = check_Click 文字 = 检查 / < span class =code-keyword>>


< / div >



Codebehind是

  protected   void  check_Click(对象发​​件人,EventArgs e)
{

var employee = _ service.GetAllEmployee();

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

}

解决方案

您是否调试过代码?检查代码流是否到达click事件处理程序?

如果代码流到达click handler,请检查_service.GetAllEmployee();


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

<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

protected void check_Click(object sender, EventArgs e)
       {

               var employee = _service.GetAllEmployee();

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

       }

解决方案

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();


这篇关于单击按钮时,如何在txtbox中显示总记录数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆