WP - How to edit selected product in windows phone using php?
Hi i am developing windows phone app. I have added product to mysql table depends upon customer_id, product_id and retailer_id. I have added table same products but different retailers.when i tap edit button i cannot edit particular product but alternatively first product only editing. so any tell me how to edit particular product depends upon cutomer id, product id and retailer id.
I will show my code given below
Code (ASP)
<StackPanel Margin="20,0,0,0" HorizontalAlignment="Left" Width="200" >
<Button Height="70" Content="EDIT" Tag="{Binding product_id}" Name="btnEdit" Foreground="White" FontWeight="Medium" BorderBrush="#57842c" BorderThickness="2,0,2,0" Margin="-18,0,0,0" Click="Edit">
<Button.Background>
<ImageBrush ImageSource="Images/submit_bg.png" Stretch="Fill" />
</Button.Background>
</Button>
</StackPanel>
Code (C#)
private void Edit(object sender, RoutedEventArgs e)
{
Button btnEdit = (Button)e.OriginalSource;
NavigationService.Navigate(new Uri("/EditWatchList.xaml?scustomerID=" + btnEdit.Tag.ToString() + "," + sretailer_id, UriKind.Relative));
}
Edit Page
Code (C#)
rivate void MainPage_Loaded(object sender, System.Windows.RoutedEventArgs e)
{
string url = "http://www.bestinuk.com/BestinUk_Windows/getProductID.php";
Uri uri = new Uri(url, UriKind.Absolute);
NavigationContext.QueryString.TryGetValue("scustomerID", out strproductID);
StringBuilder postData = new StringBuilder();
postData.AppendFormat("{0}={1}", "customer_id", HttpUtility.UrlEncode(LoginPage.strcustomer_id_k));
postData.AppendFormat("&{0}={1}", "product_id", HttpUtility.UrlEncode(strproductID));
postData.AppendFormat("&{0}={1}", "retailer_id", HttpUtility.UrlEncode(InputList.sretailer_id));
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_UploadStringCompleted;
client.UploadProgressChanged += client_UploadProgressChanged;
client.UploadStringAsync(uri, "POST", postData.ToString());
prog = new ProgressIndicator();
prog.IsIndeterminate = true;
prog.IsVisible = true;
prog.Text = "Loading....";
SystemTray.SetProgressIndicator(this, prog);
}
private void client_UploadProgressChanged(object sender, UploadProgressChangedEventArgs e)
{
//Me.txtResult.Text = "Uploading.... " & e.ProgressPercentage & "%"
}
private void client_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e)
{
if (e.Cancelled == false && e.Error == null)
{
Member myMember = ReadToObject(e.Result.ToString());
this.targetPrices.Text = myMember.target_price.ToString();
this.txtretailers.Text = myMember.retailer.ToString();
this.txtperiod.Text = myMember.period.ToString();
this.txtmobile.Text = myMember.mobile.ToString();
prog.IsVisible = false;
}
}
public static Member ReadToObject(string json)
{
Member deserializedMember = new Member();
MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(json));
DataContractJsonSerializer ser = new DataContractJsonSerializer(deserializedMember.GetType());
deserializedMember = ser.ReadObject(ms) as Member;
ms.Close();
return deserializedMember;
}
Tag : Mobile, Device (Mobile), C#, Windows Phone, Windows, Web Service
Date :
2013-09-06 13:33:26
By :
Dashi
View :
979
Reply :
1
for Example
Windows Phone Edit Update data to Web Server
Date :
2013-09-06 16:19:26
By :
mr.win
Load balance : Server 03