如何代表id获取名称.. [英] How to Get the name on behalf of id..

查看:151
本文介绍了如何代表id获取名称..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



我在文本框中有一个ID,我想代表id,名字应该显示在另一个文本框下面。我创建了一个方法但不知道在哪里调用它..请帮助我......

每当我选择id时,下面的文本框应该自动填充该特定Id的名称..





这是我的Id文本框

 <   asp:TextBox     ID   =  txtlinemanager   宽度  =  120    CssClass   =  nonwatermarked    runat   = 服务器 >  <   / asp:TextBox  >  
< asp:ImageButton ID = imgbtnbusinessheadid runat = server 工具提示 = 点击此处进行搜索......

ImageUrl = 〜/ Icons / search-button .gif OnClientClick =' 返回OpenPopup(经理);







这是名称文本框



 <   div     class   =  txtLTitleMenuEdit >  
受托人姓名< / div >
< div class = lblfullname >
< asp:TextBox ID = txtTrusteeName ReadOnly = true 宽度 = 300 CssClass = 非加水印的

< span class =code-attribute> runat = server > < div class = divnewline >
< / div >







我创建的方法是

 受保护  void  TrusteeName()
{
使用 (SqlConnection con = new SqlConnection(connectionstring))
{
using (SqlCommand cmd = new SqlCommand( 从表中选择trusteename,其中Id =' + txtlinemanager.text + ',con))
{
使用(SqlDataAdapter adapt = new SqlDataAdapter(cmd))
{
DataSet ds = new DataSet();
adapt.Fill(ds);
txttrusteename.text = ds.Tables [ 0 ]。行[ 0 ] [ trusteename]。ToString();
}

}
}
}

解决方案

< blockquote>在你的第一个文本框中将autopostback设为True,

并在textchange_event上编写你的代码


Hello,

I have an Id in textbox and I want on behalf of id ,name should be displayed in an below another textbox.I have created an method but don't know where to call it..Please Help me...
Whenever I select the id,the below textbox should automatically be filled with an name of that particular Id..


This is my Id Text Box

<asp:TextBox ID="txtlinemanager" Width="120" CssClass="nonwatermarked" runat="server"></asp:TextBox>
              <asp:ImageButton ID="imgbtnbusinessheadid" runat="server" ToolTip="Click here for search..."

                           ImageUrl="~/Icons/search-button.gif" OnClientClick=' return OpenPopup("manager");




This is name name textbox

<div class="txtLTitleMenuEdit">
                Trustee Name</div>
            <div class="lblfullname">
                <asp:TextBox ID="txtTrusteeName" ReadOnly="true" Width="300" CssClass="nonwatermarked"

                    runat="server" ><div class="divnewline">
                    </div>




The Method i have created is

protected void TrusteeName()
   {
       using (SqlConnection con = new SqlConnection(connectionstring))
       {
           using (SqlCommand cmd = new SqlCommand("select trusteename from  table where Id='" + txtlinemanager.text + "'", con))
           {
               using (SqlDataAdapter adapt = new SqlDataAdapter(cmd))
               {
                   DataSet ds=new DataSet();
                   adapt.Fill(ds);
                   txttrusteename.text = ds.Tables[0].Rows[0]["trusteename"].ToString();
               }

           }
       }
   }

解决方案

in your first textbox make autopostback as True,
and write your code on textchange_event


这篇关于如何代表id获取名称..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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