ASP.NET 2.0:用户控制一个FormView需要保存的用户数据(假人)) [英] ASP.NET 2.0: User-Control in a FormView needs to save user-data (for dummies ;))

查看:184
本文介绍了ASP.NET 2.0:用户控制一个FormView需要保存的用户数据(假人))的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发出被绑定到一个ID字段用户控件,然后使记录编辑从(各种)其他来源(通过此ID的链接)。这是工作的罚款,但我奋力抢救时保存表单数据 - 显然有更多的被不仅仅写回的id做

I have developed a user-control which gets bound to an id-field and then enables editing of records from (various) other sources (linked via this id). This is working fine, but I am struggling to save the data when the form is saved - obviously there's more to be done than "just" writing the id back.

我不希望添加额外的按钮内部更新,而是希望了解ASP.net的机制不够好,要做到这一点,他们方式,它应该做的事。不幸的是我没有成气候(和时间已经不多了),所以我希望有人能分享如何得到这个整合工作,看等,这事件的一些见解。

I wouldn't like to add extra buttons for the "inner update", but was hoping to understand the ASP.net-mechanisms well enough to do this they way it should be done. Unfortunately I'm not getting anywhere (and time is running out), so I hope someone could share some insight on how to get this integration working, which events to look at etc.

在此先感谢:)

迈克尔

修改:感谢您的意见,我想给这个想法的更多详细信息:

Edit: thanks for your comments, I'm trying to give more details on the idea:

<FormView...
   <EditItemTemplate...
      <table...
          <asp:Textbox text="<% Bind('bla1') %>...
          <uc1:MyControl id1="<%# Bind('bla2') %> editeable="True"...
          <asp:ImageButton CommandName="Update"...
...
   <ItemTemplate...
      <table...
          <asp:Textbox text="<%# Bind('bla') %>...
          <uc1:MyControl id1="bla" editeable="False"...

该用户控制UC1显示一大堆的相关记录(根据ID1) - 在编辑模式下还可以编辑/添加的这些内部的记录等。
现在,既然用户有节约,记录的标准路,我不希望通过添加特定的保存方法,只是因为我们恰好到别处编辑一些内部记录干涉。这不应该的问题给用户,用户界面​​应该具有相同的行为。这样就意味着我将不得不采取节约内部照顾。但我怎么知道用户要保存,什么是处理这个最佳实践?有没有办法用户控件可能是通知对包含控制上的更新事件,我将不得不作出明确它通过自定义更新命令等。我们正在努力使之强大和足够全面,这样就可以很容易地被重新使用。 (不过希望并不矛盾;))

This user-control uc1 displays a whole lot of related records (based on id1) - and in edit-mode also enables editing/adding etc. of these "inner" records. Now, since users have a "standard-way" of saving-records, I don't want to interfere by adding a special save-method just because we happen to edit some internal records elsewhere. That shouldn't matter to the user, UI should behave the same. So that means that I'll have to take care of saving internally. But how do I know the user wants to save and what would be a best practice to handle this? Is there a way the user-control could be "notified" about the Update-event on the containing control, would I have to make it explicit by customizing the Update-command etc. We're trying to make it robust and general enough, so that it could easily be re-used. (Still hoping that doesn't contradict ;))

推荐答案

我明白这个问题的方法是,你有你的表单按钮,但是在你的用户控件没有。然后单击该按钮时,你要坚持在用户控件所做的更改。如果是这样的话,为什么不创建一个保存所做的所有更改你的用户控件的方法,并从按钮的窗体上的单击事件调用此方法?

The way I understand this problem is that you have a button on your webform, but none on your usercontrol. Then when the button is clicked, you want to persist the changes made on the usercontrol. If this is the case, why not create a method on your usercontrol that saves all the changes made, and call this method from the click event of the button on the form?

这篇关于ASP.NET 2.0:用户控制一个FormView需要保存的用户数据(假人))的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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