开发者

Inserting with form view

开发者 https://www.devze.com 2022-12-15 12:24 出处:网络
I have a formview. With the datasource of the formview i want to insert a record into the database, but i want to insert a value i get from a method i create in code. Doesn\'t that mean that i will no

I have a formview. With the datasource of the formview i want to insert a record into the database, but i want to insert a value i get from a method i create in code. Doesn't that mean that i will not be able to directly code this onto the Data开发者_开发问答 source using the wizard?


I don't think you can get the value directly from the method, but you can get dynamic values from:

  • QueryString
  • List item
  • Cookie
  • Control
  • Form value
  • Profile
  • Session

(See here for details ==> http://msdn.microsoft.com/en-us/library/xt50s8kz.aspx)

You could put the result of your method into one of these (i.e. hidden form field or Session for example) and still use the DataSource wizard to set it all up.

If this doesn't work for you, it's fairly easy to inject dynamic values into your inserts via the ItemInserting event of the FormView control.


i would use a control paramater with controlid=__PAGE and create a property that runs the code, i have had to do this numerous times.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号