C# .net Dropdownlist 设置首选项为空
if(null!=datset&&0<datset.Tables[0].Rows.Count){ddlTempTianbaoren.DataSource=datset;d...
if (null != datset && 0 < datset.Tables[0].Rows.Count)
{
ddlTempTianbaoren.DataSource = datset;
ddlTempTianbaoren.DataTextField = "姓名";
ddlTempTianbaoren.DataBind();
ddlTempTianbaoren.SelectedIndex = -1;
ddlTempTianbaoren.Text = string.Empty;
}
这样写的没有效果,改怎么实现呢? 展开
{
ddlTempTianbaoren.DataSource = datset;
ddlTempTianbaoren.DataTextField = "姓名";
ddlTempTianbaoren.DataBind();
ddlTempTianbaoren.SelectedIndex = -1;
ddlTempTianbaoren.Text = string.Empty;
}
这样写的没有效果,改怎么实现呢? 展开
3个回答
展开全部
使用重定义代码,即可设置首选项为空。代码如下:
ddlTempTianbaoren.DataSource = datset;
ddlTempTianbaoren.DataTextField = "姓名";
ddlTempTianbaoren.DataBind();
ddlTempTianbaoren.Items.Insert(0, new ListItem());
ddlTempTianbaoren.DataSource = datset;
ddlTempTianbaoren.DataTextField = "姓名";
ddlTempTianbaoren.DataBind();
ddlTempTianbaoren.Items.Insert(0, new ListItem());
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
1 ddlTempTianbaoren.DataSource = datset;
2 ddlTempTianbaoren.DataTextField = "姓名";
3 ddlTempTianbaoren.DataBind();
4 ddlTempTianbaoren.Items.Insert(0, new ListItem());
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
ddlTempTianbaoren.DataSource = datset;
ddlTempTianbaoren.DataTextField = "姓名";
ddlTempTianbaoren.DataBind();
ddlTempTianbaoren.Items.Insert(0, new ListItem());
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询