Click here to Skip to main content
15,063,287 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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..
Whenever I select the id,the below textbox should automatically be filled with an name of that particular Id.

Please Help me...
Posted
Updated 18-Nov-13 17:07pm
v2
Comments
JoCodes 19-Nov-13 2:24am
   
Can you post what you have tried?
ajays3356 19-Nov-13 4:14am
   
This is my Id Text Box

<asp:TextBox ID="txtlinemanager" Width="120" CssClass="nonwatermarked" runat="server">
<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

Collapse | Copy Code
<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();
}

}
}
}

This Function i have created but dont know where to call it..
JoCodes 19-Nov-13 4:50am
   
Let me check whether I understood your requirement. Entering ManagerName in ManagerTextBox and clicking on searchbutton, Then the result will be shown in TrusteeNametextbox which is in a popup?
ajays3356 19-Nov-13 5:08am
   
means whenever txtlinemanager textbox is filled with some id then the txttrustname textbox should auotmatically be filled with trusteename on behalf of that particular id in txtlinemanager textbox ...
JoCodes 19-Nov-13 5:19am
   
Have posted as a solution...try and revert

Set your ID field to have autopostback = true, then call the method on postback.
   
Try as below

<asp:textbox id="TextBox1" ontextchanged="TextBox1_TextChanged" autopostback="true" runat="server" ></asp:textbox>// ManagerTextbox


In CodeBehind:

C#
protected void TextBox1_TextChanged(object sender, EventArgs e)
        {
            TrusteeName(); // assuming that this method fetches the required Trusteename from Db
        }


Hope this helps...
   
v2
Comments
ajays3356 19-Nov-13 5:20am
   
I have tried this but it shows an no object reference error...
JoCodes 19-Nov-13 5:28am
   
Can you tell me where exactly you are getting error?

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