是否是 FormView?
我有一个 ASP.NET 页面,其中包含一个包含多个表单字段页面的 Wizard 控件。数据从代码隐藏页面收集并插入到数据库中。我需要设置此表单,以便您不仅可以插入,还可以编辑记录。由于表格又长又复杂,我宁愿使用现有的表格,而不是复制一份表格进行编辑,特别是因为我想保持两种表格完全相同,并且必须对两者进行任何编辑。但看起来如果我要对其进行数据绑定,这就是我需要做的。但这还涉及将 Wizard 放入 FormView 中,然后我必须使用 FindControl 访问任何字段,这意味着更改我所有现有的代码(这当然会很耗时)。那么我应该手动输入后面代码中的所有值而不是数据绑定吗?哪个更好,使用 FormView 并具有重复的表单(加上必须进入并重做我访问字段的方式),还是从后面的代码执行所有操作?
I have an ASP.NET page with a Wizard control containing several pages of form fields. The data is collected and inserted to a database from the code behind page. I need to set this form up so you can not only insert, but edit a record as well. Since the form is long and complex, I would rather use the existing one and not make a duplicate one for editing, especially since I want to keep both forms exactly the same and any edits would have to be made to both. But it looks like this is what I need to do if I'm going to databind it. But this would also involve putting the Wizard inside of a FormView, and then I'd have to use FindControl to access any of the fields which would mean altering all my already-existing code (which of course would be time-consuming). So should I manually enter all the values from the code behind instead of databinding it? Which is better, to use a FormView and have duplicate forms (plus have to go in and redo the way I access the fields), or to do everything from the code behind?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在这种情况下作弊。 :)
将每个屏幕创建为 2 个独立的用户控件
一份用于编辑,一份用于查看
然后你就可以访问所有常用的编码
然后将控件嵌入到Wizard/FormView中
I cheat in this circumstance. :)
Create each screen as 2 separate user controls
One for edit, and one for view
Then you get access to all you usual coding
Then embed the controls into the Wizard/FormView
我建议您继续使用
FormView
,因为使用 DataBind 控件您可以更好地控制Insert/Edit/View
模板的功能和布局。由于您已经指定您的表单非常复杂且很长,因此如果您从代码隐藏进行控制,则必须做大量工作来在代码隐藏中处理此问题,并且需要大量代码。由于我有使用
FormView
开发非常复杂的表单的个人经验,并且我很容易直接在 formview 中绑定值,而不是如果您分配/获取
中每个控件的值代码隐藏,有时你必须隐藏。I would suggest you to Go Ahead using
FormView
, as using DataBind control you have more control the functionality and layoutInsert/Edit/View
template. Since you have specified that your form is very complex and long, if you control from code behind you have to do lot of work to handle this in code behind and lot code required.Since I have personal experience to develope very complex form using
FormView
and it was easy for me bind the Value in directly in formview instead if youassign/Get
Values of each conrol in code behind and sometimes you have to hide.