开发者

Add Static Item to Drop-down Programmatically LINQ

I'm binding a drop down to a radcombobox like this

    _ddActQuota.DataTextField = "DESC";
    _ddActQuota.DataValueField = "ID";

    _ddActQuota.DataSource = LNQ.tbl_job_quotas.Where(c => c.job_quota_job_number == _fJ).Select(c => new { ID = c.job_quota_ID, DESC = c.job_quota_ID + " | " + c.job_quota_desc });
    _ddActQuota.DataBind();

How can I add a initial value of ID="%%" DESC="ALL". D开发者_Python百科oing it in the markup does not work in this instance.


    var LNQ = new LNQDataContext();

    var quo = LNQ.tbl_job_quotas.Where(c => c.job_quota_job_number == _fJ).Select(c => new { ID = c.job_quota_ID, DESC = c.job_quota_ID + " | " + c.job_quota_desc });
    var DtQu = new DataTable();
    DtQu.Columns.Add("ID");
    DtQu.Columns.Add("DESC");

    DataRow drs;
    drs = DtQu.NewRow();
    drs[0] = "%%";
    drs[1] = "ALL";
    DtQu.Rows.Add(drs);

    foreach (var a in quo)
    {
        drs = DtQu.NewRow();
        drs[0] = a.ID;
        drs[1] = a.DESC;
        DtQu.Rows.Add(drs);
    }

    _ddActQuota.DataTextField = "DESC";
    _ddActQuota.DataValueField = "ID";

    _ddActQuota.DataSource = DtQu;
    _ddActQuota.DataBind();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜