如何将UserID文本框绑定到Sql server数据库表 [英] how do I bind a UserID textBox to a Sql server database table

查看:98
本文介绍了如何将UserID文本框绑定到Sql server数据库表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将XAML中的UserID文本框绑定到具有属性ID(整数)的Sql Server数据库表名People,以使用属性ID作为UserID打开新页面?

how do I bind a "UserID" textbox in XAML to a Sql Server database table name "People" with attribute "ID" (Integer),to open a new page using the attribute ID as UserID?

推荐答案

您使用的是MVVM吗?如果是这样,那么在视图模型中创建名为UserId的属性



Are you using MVVM . if so then in the view model create the property with name UserId

public int32 UserId{ get{...} set {...}}





然后在viewmodel调用方法,如wcf / webservice或sql调用,获取数据并将其分配给您创建的属性UserId。



然后在XAML页面中:





then in viewmodel call methods like wcf/webservice or sql call and get the data and assign it to the property UserId you created.

Then in the XAML page :

<textbox text="{Binding UserId}" />





我认为你会得到你想要的东西。



And I think you will get what you want.


这篇关于如何将UserID文本框绑定到Sql server数据库表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆