Hi,
I am currently using the Datepicker provided from the windows phone 7 toolkit nov 2011.
In my applicaion i have fetched the value from the datepikcker and saved it in the db without any problem.
The issue currently im facing is after that.
"I retrieved the date from the database and set it to the page in the required field. Once i click the date field to change the date, it opens the full screen date selector. After I select the requried date and click the "check button" date is not getting changed/updated in the page."
It remains the same even after changing the date from the date picker.
So far i googled i found out that "whenever i select date in datepicker it moves to new page, after selecting new date and press back button it".
Please help/provide me a suggestion to solve my current problem.
Thanks in Advance.
I have added the code behind of my project.
XAML code :
<toolkit:DatePicker Margin="139,237,0,451" x:Name="txt_DateOfPurchase" FontSize="18" Grid.ColumnSpan="2" Grid.Column="1" Width="254" ValueStringFormat="{}{0:d}" Value="" />
.CS Code
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
if (e.NavigationMode == NavigationMode.New)
{
parameterValue = NavigationContext.QueryString["parameter"];
Action = NavigationContext.QueryString["action"];
using (AppliancedataContext Appliance = new AppliancedataContext(strConnectionString))
{
var a = from b in Appliance.GetTable<ApplianceInfo>() where b.ApplianceName == parameterValue.ToString() select b;
foreach (var x in a)
{
txt_ApplianceName.Text = x.ApplianceName;
txt_DateOfPurchase.ValueStringFormat = x.DateOfPurchase;
if (Action == "EditData")
{
btnAdd.Content = "Edit";
}
if (Action == "Edit")
{
btnAdd.Content = "Edit Data";
}
}
}
}
}
private void btnAdd_Click(object sender, RoutedEventArgs e)
{
using (AppliancedataContext ApplianceDB = new AppliancedataContext(strConnectionString))
{
if (Action == "Edit" || Action == "EditData")
{
var Appliance = (from i in ApplianceDB.GetTable<ApplianceInfo>()
where i.ApplianceName == parameterValue.ToString()
select i).Single();
Appliance.ApplianceName = txt_ApplianceName.Text.ToString();
Appliance.DateOfPurchase = txt_DateOfPurchase.ValueString.ToString();
ApplianceDB.SubmitChanges();
MessageBox.Show("Updated");
}
else
{
ApplianceInfo NewAppliance = new ApplianceInfo
{
ApplianceName = txt_ApplianceName.Text.ToString(),
DateOfPurchase = txt_DateOfPurchase.ValueString.ToString(),
};
if (txt_ApplianceName.Text != "")
{
ApplianceDB.Appliances.InsertOnSubmit(NewAppliance);
ApplianceDB.SubmitChanges();
MessageBox.Show("added");
}
}
}
}