数据绑定文本框 [英] Databinding a textbox

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

问题描述

我紧随本文,并且开始学习使用ASP.NET进行数据绑定的方法;我的文本框到数据源(SQL Server db),然后

2.绑定两个不同的文本框,方式是根据日历控件的选择从数据库中查询文本框的内容.因此,当用户选择09.09.2010时,用户将能够浏览2010年9月9日的数据.

用户也应该能够从表单中CRUD(创建,读取,更新,删除)

使用用户控件来实现这一点很有意义,但是,我不得不从头开始,因为我还没有找到完整的答案.

我也尝试创建一个用户控件(因为我需要两个不同页面使用相似的UI),但是我还没有找到针对不同页面具有不同SQL数据源的解决方案(即,一个网页绑定到名为Articles的表;另一个网页绑定到名为Diary的表).建议将其作为用户控件的属性来传递,但是我尚未找到完整的代码清单,除了
我正在使用VS 2008/SQL Server 2005/Win XP SP 3/.NET 3.5 SP1.

:confused:

I''m following this article, and, getting to learn the ropes of databinding with ASP.NET; my website, however, now I''m wondering:

1. How to bind a Textbox to a datasource (SQL Server db), and,

2. Bind two different textboxes, in a way that the content of the textboxes is queried from the database depending on the selection of a calendar control. So when the user selects 09.09.2010, the user would be able to browse for data for 09.09.2010.

The user should be able to CRUD (create, read, update, delete) from the forms as well

It would make sense to implement this using a user control, however, I had to start from scratch because I haven''t found complete answers as yet.

I also tried creating a user control (because I need similar UI for two different pages), however I haven''t found a solution for having different SQL Data Sources for different pages (i.e. one webpage binds to a table named Articles; another webpage binds to a table named Diary). It was suggested to pass this as a property of the user control, however I haven''t found a complete code listing as yet, other than this hint. :confused:

It would also make sense to use masterpages for my website, however, I had to ''copy and paste'' my navigation bar because there was a problem with placing content.

I have tried to use <asp:formview xmlns:asp="#unknown"> for this purpose as well, however, it did not seem to work.

I''m using VS 2008 / SQL Server 2005 / Win XP SP 3 / .NET 3.5 SP1.

:confused:

推荐答案

对于第1点和第2点,您可以将TextBoxes放在Repeater中并将其与数据源绑定,并需要根据更改来更新数据源日历事件.
For your point 1 & 2, you can place the TextBoxes in a Repeater and Bind it with your datasource and need to update your datasource on the change event of calendar.


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

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