一个数据操作问题
<asp:GridView ID= "gv " ........./>
<asp:DetailsView ID= "dv " runat= "server " DataSourceID= "ds "/>
<Fields>
<asp:BoundField DataField= "bb " HeaderText= "bb " SortExpression= "bb " />
<asp:BoundField DataField= "cc " HeaderText= "cc " SortExpression= "cc " />
<asp:BoundField DataField= "dd " HeaderText= "dd " SortExpression= "dd " />
<asp:BoundField DataField= "ee " HeaderText= "ee " SortExpression= "ee " />
</Fields>
</asp:DetailsView>
<asp:AccessDataSource runat= "server " ..........
SelectCommand= "SELECT aa, bb, cc, dd, ee, ff FROM A WHERE (aa=@aa) "
InsertCommand= "INSERT INTO A (bb, cc, dd, ee, ff) VALUES (@bb, @cc, @dd, @ee, @ff) "
<SelectParameters>
<asp:ControlParameter ControlID= "gv " Name= "aa " PropertyName= "SelectedValue " Type= "String " />
</SelectParameters>
<InsertParameters>
<asp:ControlParameter ControlID= "gv " Name= "ff " PropertyName= "SelectedValue " Type= "String " />
</InsertParameters>
</asp:AccessDataSource>
dv执行插入操作异常, dv只有4个可见字段bb、cc、dd、ee, 在插入时, 我需要加一个ff, ff为gv.SelectedValue
大虾们, 为达到目的该怎么做?
------解决方案---------------------_-!好像很容易呀,一个挺入语句exe下那个sql就行了
------解决方案--------------------添加不可见的字段绑定试试呢?
<asp:DetailsView ID= "dv " runat= "server " DataSourceID= "ds "/>
<Fields>
<asp:BoundField DataField= "bb " HeaderText= "bb " SortExpression= "bb " />
<asp:BoundField DataField= "cc " HeaderText= "cc " SortExpression= "cc " />
<asp:BoundField DataField= "dd " HeaderText= "dd " SortExpression= "dd " />
<asp:BoundField DataField= "ee " HeaderText= "ee " SortExpression= "ee " />
<asp:BoundField DataField= "ff " Visible= "False " />
</Fields>
</asp:DetailsView>
------解决方案--------------------大哥,难道 Insert 中的其他参数你就不指定了吗?
什么异常也不说 ....
是不是告诉 什么什么参数没有提供啊
------解决方案-------------------- <InsertParameters>
<asp:Parameter Name= "bb " Type= "String " />
<asp:Parameter Name= "cc " Type= "String " />
<asp:Parameter Name= "dd " Type= "String " />
<asp:Parameter Name= "ee " Type= "String " />
<asp:ControlParameter ControlID= "gv " Name= "ff " PropertyName= "SelectedValue " Type= "String " />
</InsertParameters>
注意,以上的 Type 根据实际参数数据类型修改之
------解决方案--------------------