[RESOLVED]Populate Textbox/FormView based on selection

<div itemprop="text" class="parsed-message clear">

Hi, I am currently working on an assignment and am stuck on the very end of it.
In a previous assignment we created a SQL database and GUI in vs C# for this one we have to turn this into a web service, I have all forms working apart from one.

I need to be able to type a customersID into the box at the top click the button and populate the fields below based on what ID has been selected..it sounds easy but I can’t get it to work. I have looked at the option of making it into a dropdownlist and
populating the textboxes based on what is selected in that, i have spent hours researching and can’t find a way to make it work in a webservice.

If anyone has any ideas on what I should be doing, I would be forever Greatful!!


Hi Roisin,

Can you post your webservice code please.

If you have a textbox where the user can enter a value and then press submit which in return will load everything associated with that Id then you could use Jquery for this.

But post your code so we can check it out.


Typed this on my phone so not sure if its 100% bullet proof.

// Html for tetbox and button

<input type="textbox" id="txtCustomerId"/>
<button type="submit" id="btnFindCustomer">Find<button>

// Javascript section to call WebMethod to return customer name

<script type="text/javascript">

$(document).ready(function (){
$("#btnFindCustomer").click(function (){
$.ajax({ type: "POST", url: "YourPage.aspx/GetCustomerName", data: {customerId: $('#txtCustomerId').val()}, dataType: "json", success: function(msg) { // Do something with results msg.d alert(msg.d); }, error:function(){ alert('opps'); } }); }); }); </script> // Code behind [WebMethod] public static string GetCustomerName(string customerId) { // Modify this function to return the relevant values from the db return "CustomerName"; }

Leave a Reply