我正在绑定一个像这样的radcombobox
_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();
如何添加ID =“%%”的初始值DESC =“ALL”。在标记中执行此操作在此实例中不起作用。
答案 0 :(得分:0)
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();