Jump to content

Populating text box with results

- - - - -

  • Please log in to reply
7 replies to this topic

#1
aakinn

aakinn

    Newbie

  • Members
  • PipPip
  • 24 posts
Hello all

I have the following code which submits data to a web service and I want to display the items found in a text box here is my what I have so far

        protected void btnSubmit_Click(object sender, EventArgs e)

        {

            WebApplication4.serviceRef.SearchService search = new WebApplication4.serviceRef.SearchService();


            List<WebApplication4.serviceRef.Project> listproj = new List<WebApplication4.serviceRef.Project>();

            listproj = search.SearchWithStringParamters(txtMainTech.Text, txtHours.Text, txtEffort.Text, txtStDate.Text).Projects.ToList();

            for (int i = 0; i < listproj.Count; i++)

            {

                string projList = listproj.ToString();

                txtresult.Text = projList;

            }

        }


#2
cdg10620

cdg10620

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 389 posts
What does your WebService look like? Are you passing back the response in XML? You should be able to grab that response and set the text. What are you getting back from the Web Service right now?
-CDG10620
Software Developer

#3
aakinn

aakinn

    Newbie

  • Members
  • PipPip
  • 24 posts
Currently

System.Collections.Generic.List`1[WebApplication4.serviceRef.Project]

Is being displayed in the textbox . . . I dont want the xml to be returned just simply a list of all the search results

#4
cdg10620

cdg10620

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 389 posts
I understand that but the webservice is going to return one of two things: either XML or JSON and you will need to read the results and use that data to populate the textbox.
-CDG10620
Software Developer

#5
aakinn

aakinn

    Newbie

  • Members
  • PipPip
  • 24 posts
The results from the web service are in XML

#6
gokuajmes

gokuajmes

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 518 posts
could you explain more on what you intend to do with the response XML

WOOH
for (int i = 0; i < listproj.Count; i++)
            {
                string projList = listproj.ToString();
                txtresult.Text = projList;
            }

This code does nothing man Unless the Object you are iterating is a an Array !!

#7
aakinn

aakinn

    Newbie

  • Members
  • PipPip
  • 24 posts
The output of the xml is thus

      
<Result>
<Projects>
<Project>
<EntityKey>
<EntitySetName>Project</EntitySetName>
<EntityContainerName>ProjectDBEntities1</EntityContainerName>
<EntityKeyValues>
<EntityKeyMember>
<Key>ProjectId</Key>
<Value xsi:type="xsd:int">1</Value>
</EntityKeyMember>
</EntityKeyValues>
</EntityKey>
<ProjectId>1</ProjectId>
<ProjectName>Project 1</ProjectName>
<EstimatedHours>50</EstimatedHours>
<EstimatedEffort>10</EstimatedEffort>
<MainTechnology>Java</MainTechnology>
<dteStart>2010-01-01T00:00:00</dteStart>
<dteEnd>2010-01-31T00:00:00</dteEnd>
<Active>true</Active>
−
<AdministratorReference>
−
<EntityKey>
<EntitySetName>Administrator</EntitySetName>
<EntityContainerName>ProjectDBEntities1</EntityContainerName>
−
<EntityKeyValues>
−
<EntityKeyMember>
<Key>AdministratorId</Key>
<Value xsi:type="xsd:int">1</Value>
</EntityKeyMember>
</EntityKeyValues>
</EntityKey>
</AdministratorReference>
</Project>
</Projects>
<IsExactMatch>true</IsExactMatch>
</Result>

I want to extract all the entity values ie ProjectName, MainTechnology, EstimatedHours etc.. and display them in the textbox

#8
cdg10620

cdg10620

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 389 posts
You should probably de-serialize it to an object and then use each of the properties and bind to the textbox text.
-CDG10620
Software Developer




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users