我的问题是将数据以xamarin的形式插入到firebase中。这是我的CreateAccount.xaml。
<Picker
Title="Select Security Question"
TextColor="Black"
HorizontalOptions="StartAndExpand"
FontSize="Medium"
WidthRequest="250"
TitleColor="Black"
x:Name="entryField_SecurityQuestion"
>
<Picker.Items
>
<x:String>
Who is your first love?
</x:String>
<x:String>
what subject you failed?
</x:String>
<x:String>
What is the name of your dog?
</x:String>
<x:String>
Who is your first kiss?
</x:String>
</Picker.Items>
</Picker>
codebehind.cs
async public void signButton_Clicked(System.Object sender, System.EventArgs e)
{
Picker picker = sender as Picker;
//this is how I manage my some ID from my front end
string firstName = entryField_Firstname.Text;
string lastName = entryField_Lastname.Text;
string contactNumber = entryField_PhoneNumber.Text;
string securityQuestion = picker.SelectedItem.ToString(); // this line is my trial and error, I tried some code but I cant insert data to database
Customer customer = new Customer();
customer.FirstName = firstName;
customer.LastName = lastName;
customer.SecurityQuestion = securityQuestion;//this one also, this is my trial and error approach
customer.ContactNumber = contactNumber;
var Savedata = await customerRepo.Save(customer);
}
`
我希望,我可以得到采摘的项目,并将其保存到数据库。任何链接,将张贴相关的我的职位,将不胜感激。谢谢你这么多
1条答案
按热度按时间pepwfjgg1#
如果你想得到Picker的
SelectedItem
,你需要引用你的picker的x:Name="entryField_SecurityQuestion"
而不是Picker picker = sender as Picker;
,就像Jason说的那样。可以参考下面的代码: