Click here to Skip to main content
15,902,114 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
XML
<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

XML
<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
C#
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();
               }

           }
       }
   }
Posted
Updated 18-Nov-13 6:54am
v3
Comments
ZurdoDev 18-Nov-13 11:23am    
Then call the code when you select the id.
ajays3356 18-Nov-13 11:26am    
how, can you give me an example please..
ZurdoDev 18-Nov-13 11:26am    
Not until you post your relevant code. Are you using a dropdown, textbox, listbox, we have no idea what you have. Use the Improve Question link and add relevant code.
ajays3356 18-Nov-13 11:36am    
I have updated the question now please tell me.
ZurdoDev 18-Nov-13 11:45am    
Personally, I would use jquery and the onchange event of the textbox. Or, you can set your textbox to autopostback and then use the Text_Changed event.

1 solution

in your first textbox make autopostback as True,
and write your code on textchange_event
 
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