2012年4月18日

如何判断数据库中取出的某个字段为空

摘要: 如果通过name字段在数据库中为空值,用data.Tables[0].Rows[0]["AlarmFlag"] !=null判断得到的结果为true,原因为AlarmFlag字段读出来为system.DBNull其中AlarmFlag为tinyint类型正确的判断方法是data.Tables[0].Rows[0]["AlarmFlag"] != System.DBNull.Value也可以用下面的方法data.Tables[0].Rows[0]["AlarmFlag"].ToString()!=""附:null表示 阅读全文

posted @ 2012-04-18 11:13 黄兆张's Blog 阅读(6919) 评论(0) 推荐(0) 编辑

ASP.NET DridView 显示行号

摘要: 方法一aspx GridView 添加OnDataBound="GridView1_DataBound"和<asp:TemplateField ItemStyle-Width="50px" ItemStyle-HorizontalAlign="Center"> <HeaderTemplate> 序号</HeaderTemplate> <ItemTemplate> <asp:Label ID="Label1" runat="server" Te 阅读全文

posted @ 2012-04-18 09:57 黄兆张's Blog 阅读(712) 评论(0) 推荐(0) 编辑

ASP.NET dropdownlist绑定数据却显示System.Data.DataRowView

摘要: 问题: 在VS中用dropdownlist控件绑定数据,浏览时却在控件里显示System.Data.DataRowView,而不是要显示的数据,代码如下: /// <summary> /// 绑定DropDownList /// </summary> private void ListBind() { //功能列表 DataSet ds = bllPower.GetAllList(); this.DDLPower_Id.DataSource = ds; this.DDLPower_Id.DataBind(); this.DDLPower_Id.Items.Insert( 阅读全文

posted @ 2012-04-18 09:20 黄兆张's Blog 阅读(377) 评论(0) 推荐(0) 编辑

导航