public void BindYijiCarType()
{
IList<Car_Type> list = (from c in cc.Car_Type where c.car_type_parentId == 0 select c).ToList();
if (list == null)
{
this.ddlYIji.Items.Insert(0, "--请添加--");
this.ddlYIji.DataBind();
}
else
{
this.ddlYIji.DataSource = list;
this.ddlYIji.DataBind();
this.GridView1.DataSource = list;
this.GridView1.DataBind();
}
}
然后在Page_load当中加载,如果为空的话,怎么dropdownList还是什么都没有????
解决方案 »
- 百万条数据,如何提高查询、比较以及更新处理的速度
- 关于存储过程的调用
- DES加密,高手来看看
- c# 如何判断字符串是否为 decimal 类型
- Crystal Reports 使用dataset登录的问题。
- 100分﹐解決就給,Up也有(input file 和 按鈕得使用問題)
- 求助:无法生成sql server的用户实例 仅集成连接才可以生成实例
- WebGrid控件中对数据时行编辑时如何在相应记录字段中显示下拉列表框?
- Response.Write()带参数的时候怎样跳转页面???
- 微软Office组件调用的奇怪问题,真诚求大神解答
- jQuery Media Plugin 怎么用啊
- js怎么保存之前的树形的结构状态呢?
永远不为null,没有时长度为0,不是null
{
string sql = "select p_pid,p_name from p_product where p_cid=3";
DataTable dt3 = sqlhelper.GetTable(sql);
for (int i = 0; i < dt3.Rows.Count; i++)
{
ListItem li = new ListItem(dt3.Rows[i]["p_name"].ToString(), dt3.Rows[i]["p_pid"].ToString());
drop3.Items.Add(li);
}
}
改成:if(list.count==0)
试试