|
|
|
WP - pass the id from one page to next page depends upon selecteditem in windows phone |
|
|
|
|
|
|
|
Hi.,
I am developing an one windows phone application.i have facing following issues.
I need to delete the selected item from the list.but unable to delete the selected item.
The last item only deleted when am selecting any item from that list.What's wrong in my code and concepts ???
please give me any suggestions ...
I have using following code on my app:
I have using below query for delete the selected item.
Code (PHP)
if (isset($_POST['product_id']) && isset($_POST['customer_id'])) {
$product_id = $_POST['product_id'];
$customer_id = $_POST['customer_id'];
// mysql update row with matched pid
$result = mysql_query("DELETE FROM pim_productdeal WHERE product_id = $product_id AND customer_id = $customer_id");
The below code for getting the list :
Code (C#)
private void client_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e)
{
if (e.Cancelled == false && e.Error == null)
{
MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(e.Result));
ObservableCollection<Member> list = new ObservableCollection<Member>();
DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(ObservableCollection<Member>));
list = (ObservableCollection<Member>)serializer.ReadObject(ms);
List<Member> myCustomer = new List<Member>();
foreach (var cm in list)
{
string scustomerID = cm.customer_id;
sproductID = cm.product_id;
sproduct_name = cm.product_name.ToString();
myCustomer.Add(new Member(scustomerID, sproductID, sproduct_name));
}
i have to delete the product depends upon selecteditem:
Code (C#)
private void Remove(object sender, RoutedEventArgs e)
{
NavigationService.Navigate(new Uri("/DeletewatchList.xaml?sproductid=" + sproductID, UriKind.Relative));
}
The following code for delete functionality:
Code (C#)
private void MainPage_Loaded(object sender, System.Windows.RoutedEventArgs e)
{
MessageBoxResult result = MessageBox.Show("Are you sure want to delete?", "Delete Message", MessageBoxButton.OKCancel);
if (result == MessageBoxResult.OK)
{
string url = "http://www.bestinuk.com/BestinUk_Windows/deleteproduct.php";
Uri uri = new Uri(url, UriKind.Absolute);
NavigationContext.QueryString.TryGetValue("sproductid", out sproductID);
StringBuilder postData = new StringBuilder();
postData.AppendFormat("{0}={1}", "product_id", HttpUtility.UrlEncode(InputList.sproductID));
postData.AppendFormat("&{0}={1}", "customer_id", HttpUtility.UrlEncode(LoginPage.strcustomer_id_k));
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_UploadStringComplete;
client.UploadProgressChanged += client_UploadProgressChangedes;
client.UploadStringAsync(uri, "POST", postData.ToString());
prog = new ProgressIndicator();
prog.IsIndeterminate = true;
prog.IsVisible = true;
prog.Text = "Loading....";
SystemTray.SetProgressIndicator(this, prog);
}
else
{
NavigationService.Navigate(new Uri("/InputList.xaml?selectedItem=", UriKind.Relative));
}
please read my question and give me solution.
The list of product is displaying well.
if i have to delete the any product from these list means the last product only deleted from that list.
For EG:
The list having 3 products.now i have to delete the second product means the 3rd product only deleted from these list.
please check my code.why am facing these problem .
What's wrong in my code ??? please give me any suggestions ....
Tag : Mobile, MySQL, Device (Mobile), C#, Windows Phone, Windows
|
|
|
|
|
|
Date :
2013-08-17 20:58:43 |
By :
li |
View :
1131 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Sample
Windows Phone Edit Update data to Web Server
|
|
|
|
|
Date :
2013-08-21 06:36:59 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|