ASP.NET从入门到精通第23注册登陆 问题
发表在ASP.NET图书答疑 2016-11-29
是否精华
版块置顶:

把登录注册实例原样传服务器上,管理员登陆和会员登录,出现下列代码,请问都是什么问题?书上出错还是其他原因?如何改正?

管理员登陆错误
Server Error in '/' Application.


DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'UserID'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Web.HttpException: DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'UserID'.

Source Error: 


Line 32:                                     <td style="width: 90px">
Line 33:                                         <asp:Button ID="btnEdit" runat="server" CommandName="edit" Text="编辑" />
Line 34:                                         <asp:Button ID="btnDelete" runat="server" CommandName="delete" Text="删除" CommandArgument='<%# DataBinder.Eval(Container.DataItem,"UserID") %>' OnLoad="btnDelete_Load" /></td>
Line 35:                                     <td style="width: 86px">
Line 36:                                         <asp:Button ID="btnSetRole" runat="server" CommandName="setRole" Text='<%# (bool) DataBinder.Eval(Container.DataItem,"Role")==true?"取消管理员权限":"设为管理员权限" %>' CommandArgument = '<%# DataBinder.Eval(Container.DataItem,"UserID") %>'/></td>

Source File: d:\freehost\zszq888\web\UserManagement.aspx    Line: 34 


会员登陆错误

Server Error in '/' Application.


Object cannot be cast from DBNull to other types.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.InvalidCastException: Object cannot be cast from DBNull to other types.

Source Error: 


Line 18:         if (!IsPostBack)
Line 19:         {
Line 20:             if (Convert.ToBoolean (Session["Role"]))
Line 21:                 selVal = "";
Line 22:             else

Source File: d:\freehost\zszq888\web\UserManagement.aspx.cs    Line: 20 

2016-11-30 20:25:30编辑
分享到:
精彩评论 1
小禾斗
学分:7308 LV13
TA的每日心情
奋斗
2017-04-21 14:00:25
2016-12-01
沙发

我们测试了一下,程序是好使的,建议检查一下数据库,看看tb_User数据表中是否存在UserID这个字段。

首页上一页 1 下一页尾页 1 条记录 1/1页
手机同步功能介绍
友情提示:以下图书配套资源能够实现手机同步功能
明日微信公众号
明日之星 明日之星编程特训营
客服热线(每日9:00-17:00)
400 675 1066
mingrisoft@mingrisoft.com
吉林省明日科技有限公司Copyright ©2007-2022,mingrisoft.com, All Rights Reserved长春市北湖科技开发区盛北大街3333号长春北湖科技园项目一期A10号楼四、五层
吉ICP备10002740号-2吉公网安备22010202000132经营性网站备案信息 营业执照