错误一:删除数据的时候出现问题:必须声明标量变量 "@ID"
解决办法:
SQL语句:DELETE FROM BACKOUT_RS WHERE ID=@ID
然后将<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1">改成
<asp:GridView ID="GridView1" runat="server" DataKeyNames="ID" DataSourceID="SqlDataSource1">
就可以了,也就是把ID定义为主键。
错误二:更新时不能实现nvarchar到money转换
解决方法:
SQL语句:UPDATE BACKOUT_RS SET
BODEPRECIATION = CAST(@BODEPRECIATION AS money), BOEQU = CAST(@BOEQU AS money), BTOA = CAST(@BTOA AS money), ATOB = CAST(@ATOB AS money), BOPOSITADDRESS = @BOPOSITADDRESS, BOAREA = @BOAREA, Remark=@Remark
WHERE ID = @ID
错误三:不能实现多控件时,当其他控件的值空时继续进行查询
解决方法:SELECT BACKOUT_RS.* FROM BACKOUT_DESC INNER JOIN BACKOUT_RS ON BACKOUT_DESC.ID = BACKOUT_RS.BOAREA
where (BACKOUT_DESC.NAME=@myname3 or @myname3='all') and (BOHOUSE_OWNER=@houseowner or @houseowner='a') and (BOADDRESS=@boaddress or @boaddress='a') and (BOPOSITADDRESS=@myaddress or @myaddress='a')
然后将 其余控件的参数值DefaultValue设为a
错误四:格式化日期不能成功
解决方法:<asp:BoundField DataField="BOTIME" HeaderText="拆迁时间"
DataformatString="{0:yyyy-MM-dd}" HtmlEncode="false" SortExpression="BOTIME" />
货币类型格式化
<asp:BoundField DataField="BODEPRECIATION" HeaderText="旧房折价" DataFormatString="{0:C}"HtmlEncode="False"SortExpression="BODEPRECIATION" />
错误五:无法实现在IE浏览器中显示gridview的中文数据不换行
解决方法:<asp:BoundField DataField="BOID" HeaderText="拆迁编号" SortExpression="BOID" >
<ItemStyle Wrap="False" />
<HeaderStyle Wrap="False"/>
</asp:BoundField>
后来发现其实在编辑列的每个字段中都有一个wrap属性,每个字段都设置wrap为false也能成功