我在我的DeatilView控件中定义了一个InsertItemTemplate。在这个模板中,我有一些用户填充的字段和一些自动填充的字段,用户不能更改它们。这些值来自会话中存储的对象。
代码如下所示:(我只提必要的部分,如果你需要更多的东西让我知道)ASP.NET DetailView InsertItemTemplate
<asp:DetailView ... DataSourceID="MyDataSource" ...>
<Fields>
...
<InsertItemTemplate>
// These are the fields filled by the system
<asp:Label ... Text='<%# some value from session object %>' />
<asp:Label ... Text='<%# some value from session object %>' />
// some textboxes here that user fills,
//they use Bind("some data source value here") to send their data to database
...
</InsertItemTemplate>
...
</Fields>
</asp:DetailView>
现在的问题是,我需要真正的值插入数据库。
正文发送文本框值,但由于我没有绑定标签值,因此它们不会发送到DataSource。所以我问如何做到这一点?
- 我找到了一个替代方法是传递一个默认值到DataSet的 各自InsertParameter,但我不知道如何来填补这一领域 得到它从会话值。
- 另一种方法是设置参数的值(不是默认值) 从会议,这是可能的,但这种只支持采取 值是直接在会话,而我通过内部的的 一个属性的值存储在Session中的对象。有没有 方法来解决这个问题,除了直接在会话 中存储值之外。
如果按类型表示DataSourceMode,那么我没有指定任何,我认为默认情况下意味着DataSet模式。 – atoMerz
不,我的意思是SqlDataSource,ObjecDataSource,LinqDataSource等。 – boades
或者你从代码隐藏中设置deatails视图的DataSource对象? – boades