2013-08-27 3 views
0

안녕하세요, 저는 Windows phone 앱을 개발 중입니다. 나는 listpicker 선택된 데이터를 mysql 테이블 php에 저장할 필요가있다. 선택한 데이터를 저장하면 클래스 이름이 저장됩니다. 그래서 나는 내 code.please 아래 주어진이 문제에서 해결하는 방법을 말해.windows에서 선택한 데이터를 선택하는 방법 picker 전화 번호

이 내 XAML 코드

<toolkit:ListPicker x:Name="RetailerList" ItemsSource="{Binding Retailerslist}" Foreground="Black" BorderThickness="0" Margin="30,-1,39,0" > 
     <toolkit:ListPicker.ItemTemplate> 
      <DataTemplate> 
        <TextBlock Text="{Binding retailername}" FontSize="20" FontFamily="Arial" Foreground="Black" TextWrapping="Wrap" /> 
       </DataTemplate> 
     </toolkit:ListPicker.ItemTemplate> 
</toolkit:ListPicker> 

내 C# 코드는 PHP를 사용하여 MySQL의 테이블에 XML 피드에서 데이터 저장

Producttype = articles.Element("Retailers").Elements("Retailer") 
       .Select(retail => new BestinukRetailers          
       { 
        retailername = retail.Attribute("name").Value 
       }).ToList(), 


    protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) 
    { 
     string selectedIndex = ""; 
     if (NavigationContext.QueryString.TryGetValue("scustomerID", out selectedIndex)) 
     { 
      RetailerList.ItemsSource = App.ProductList.Producttype; 
     } 
    } 

내 클래스 이름

public class BestinukProduct 
{ 
    public List<BestinukRetailers> Producttype { get; set; } 

    public string ProductName { get; set; } 
} 

public class BestinukRetailers 
{ 

    public string retailername { get; set; } 
} 

내 C 번호를 검색입니다입니다

 string url = "http://www.best.com/Best_Windows/insert.php"; 
     Uri uri = new Uri(url, UriKind.Absolute); 


     StringBuilder postData = new StringBuilder(); 
     postData.AppendFormat("{0}={1}", "product_id", HttpUtility.UrlEncode(ProductDetails.productId)); 
     postData.AppendFormat("&{0}={1}", "customer_id", HttpUtility.UrlEncode(LoginPage.strcustomer_id_k)); 

     postData.AppendFormat("&{0}={1}", "retailer",HttpUtility.UrlEncode(this.RetailerList.SelectedItem.ToString())); 

     WebClient client = default(WebClient); 
     client = new WebClient(); 
     client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded"; 
     client.Headers[HttpRequestHeader.ContentLength] = postData.Length.ToString(); 

     client.UploadStringCompleted += client_SaveUploadStringCompleted; 
     client.UploadProgressChanged += client_SaveUploadProgressChanged; 

     client.UploadStringAsync(uri, "POST", postData.ToString()); 

     prog = new ProgressIndicator(); 
     prog.IsVisible = true; 
     prog.Text = "Connecting update to server...."; 
     SystemTray.SetProgressIndicator(this, prog); 

내가 성공적으로 데이터베이스에 데이터를 저장할 수 있지만 클래스 이름 이군에 저장합니다이 이미지 아래에 주어진하고하는 것은 내가 아웃이

enter image description here

를 넣어 가지고 있습니다이 이미지 내가 나왔고 선택된 데이터를 검색입니다 때 이미지 넣기. 그래서 하나 개주고 솔루션이 어떻게 목록 선택 도구를 선택 data.Advance 감사합니다 .. 저장하십시오

답변

0

문제는 줄입니다 :

postData.AppendFormat("&{0}={1}", "retailer",HttpUtility.UrlEncode(this.RetailerList.SelectedItem.ToString())); 

this.RetailerList.SelectedItemBestinukRetailers 객체를 반환합니다. 필요한 것은 해당 객체의 retailername 속성입니다. 를 검색하려면

, 단순히 원래의 형태로 객체를 캐스팅 :

var retailer = (BestinukRetailers)this.RetailerList.SelectedItem; 
postData.AppendFormat("&{0}={1}", "retailer",HttpUtility.UrlEncode(retailer.retailername)); 
+0

안녕 KooKiz는 대답을 얻었다 당신의 replay.I 주셔서 감사합니다. – user123