天天看点

.net后台设置DropDownList默认值

if (ds.Tables[0].Rows[0]["获奖等级"].ToString() != null)
        {
            drop_获奖等级.ClearSelection(); //必须加 不加会提示不能绑定多值
            drop_获奖等级.Items.FindByText(ds.Tables[0].Rows[0]["获奖等级"].ToString()).Selected = true;
        }
        if (ds.Tables[0].Rows[0]["教材类型"].ToString() != null)
        {
            drop_教材类别.ClearSelection();
            drop_教材类别.Items.FindByText(ds.Tables[0].Rows[0]["教材类型"].ToString()).Selected = true;
        }
        if (ds.Tables[0].Rows[0]["教材性质"].ToString() != null)
        {
            drop_教材性质.ClearSelection();
            drop_教材性质.Items.FindByText(ds.Tables[0].Rows[0]["教材性质"].ToString()).Selected = true;
        }