我想将字段值作为ObjectDataSource的更新参数传递,但此字段未显示在查看控件中: 这是代码:
<asp:ObjectDataSource ID="ObjectDataSourceCurrentItem" runat="server" SelectMethod="GetItemByID"
InsertMethod="InsertItem" UpdateMethod="UpdateItem" TypeName="Item">
</asp:ObjectDataSource>
<asp:DetailsView ID="DetailsViewCurrentItem" runat="server" AutoGenerateRows="False" Height="50px" Width="50%"
DataSourceID="ObjectDataSourceCurrentItem" AutoGenerateInsertButton="True" AutoGenerateEditButton="True"
DataKeyNames="ID" DefaultMode="Insert"
OnItemInserted="DetailsViewCurrentItem_ItemInserted"
OnItemUpdated="DetailsViewCurrentItem_ItemUpdated" OnItemCommand="DetailsViewCurrentItem_ItemCommand">
<FieldHeaderStyle Width="100px" />
<Fields>
<asp:BoundField ItemStyle-HorizontalAlign="Right" DataField="Title"
SortExpression="Title" ControlStyle-Width="45%" />
<asp:BoundField DataField="Description" SortExpression="Description"
ControlStyle-Width="45%" />
<asp:BoundField ItemStyle-HorizontalAlign="Right" DataField="URL"
SortExpression="URL" ControlStyle-Width="45%" />
</Fields>
</asp:DetailsView>
“Item”类型在DetailsView中没有显示另一个字段“Version” 我想将其作为UpdateParameter传递给“ObjectDataSourceCurrentItem” 这该怎么做? 谢谢
答案 0 :(得分:0)
试试这个
<asp:ObjectDataSource ID="ObjectDataSourceCurrentItem" runat="server" SelectMethod="GetItemByID"
InsertMethod="InsertItem" UpdateMethod="UpdateItem" TypeName="Item">
<UpdateParameters>
<%--past here your update parameter--%>
</UpdateParameters>
</asp:ObjectDataSource>
<asp:DetailsView ID="DetailsViewCurrentItem" runat="server" AutoGenerateRows="False" Height="50px" Width="50%"
DataSourceID="ObjectDataSourceCurrentItem" AutoGenerateInsertButton="True" AutoGenerateEditButton="True"
DataKeyNames="ID" DefaultMode="Insert"
OnItemInserted="DetailsViewCurrentItem_ItemInserted"
OnItemUpdated="DetailsViewCurrentItem_ItemUpdated" OnItemCommand="DetailsViewCurrentItem_ItemCommand">
<FieldHeaderStyle Width="100px" />
<Fields>
<asp:BoundField ItemStyle-HorizontalAlign="Right" DataField="Title"
SortExpression="Title" ControlStyle-Width="45%" />
<asp:BoundField DataField="Description" SortExpression="Description"
ControlStyle-Width="45%" />
<asp:BoundField ItemStyle-HorizontalAlign="Right" DataField="URL"
SortExpression="URL" ControlStyle-Width="45%" />
</Fields>
</asp:DetailsView>