Using same datasource for textbox as listbox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • E11esar
    New Member
    • Nov 2008
    • 132

    #1

    Using same datasource for textbox as listbox

    Hi there.

    I am looking to use a dataset return from a webservice that is currently populating a listbox, to also populate a value in a textbox that is loaded once an item is selected from the listbox.

    My code for the above part that populates the listbox is as follows and this works fine.

    Code:
    listBox.DataSource = myWebService.MethodName(param1, param2);
    listBox.DataValueField = "RETURN_DETAILS_ONE";
    listBox.DataBind();
    What I am wondering is whether or not I can use this same returned dataset that is used in the listbox datasource, as the data for a textbox, which will be populated once an item is selected from the listbox?

    As I am not setting a name to the dataset/datasource I am then wondering if I can then reuse this same data?

    Thank you.

    M :)
  • E11esar
    New Member
    • Nov 2008
    • 132

    #2
    More information

    Hi again.

    I have made a small change in that I have declared a dataset and then used this to fetch the data from the webservice as follows:

    Code:
    DataSet ds1;
    ds1 = myWebService.MethodName(param1, param2);
    listBox.DataSource = ds1;
    listBox.DataValueField = "RETURN_DETAILS_ONE";
    listBox.DataBind();
    
    lbResults.DataSource = ds1;
    In effect I want to use another value that is returned by the webservice and once an item is selected from the listbox, so use this respective value in my textbox.

    Hope that makes sense..?

    Thank you.

    M :)

    Comment

    • Blacky
      New Member
      • Jan 2009
      • 40

      #3
      First of all, you cant set a datasource property to textbox, if you want to load the same data that is selected in listbox, you can very well go for Listbox-SelectedIndexch ange event and use

      Txtbox1.text = listbox1.select editem.value.to string();

      thanks in advance
      Blacky

      Comment

      Working...