【发布时间】:2022-12-01 10:33:54
【问题描述】:
我的问题是以 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);
}
`
我希望,我可以获得选择器的项目,并将其保存到数据库中。 将发布与我的帖子相关的任何链接,将不胜感激。太感谢了
【问题讨论】:
-
按钮点击事件的
sender是Button而不是Picker。您已经为您的 `Picker 分配了一个名称,所以只需使用该名称来引用它
标签: firebase xamarin.forms picker