I have a ASPxComboBox
for which I'm binding data based on 2 conditions.
Now,I need to show Color
for items in combobox
based on condition.
My Code :
var dataMainBranchUsers = (from xx in VDC.SURVEY_USER_DETAILS
where xx.BRANCH_ID == 1 && (xx.USER_LEVEL == 2 || xx.USER_LEVEL == 5)
select new
{
xx.USER_NAME,
xx.USER_ID,
xx.USER_LEVEL
}).ToList();
DataTable dtMainBranchUsers = LINQToDataTable(dataMainBranchUsers);
for (int i = 0; i < dtMainBranchUsers.Rows.Count; i++)
{
string strlevel = dtMainBranchUsers.Rows[i]["USER_LEVEL"].ToString();
string struser = dtMainBranchUsers.Rows[i]["USER_NAME"].ToString();
if (strlevel == "2")
{
dtMainBranchUsers.Rows[i]["USER_NAME"] = struser + " - Admin";
}
else
{
dtMainBranchUsers.Rows[i]["USER_NAME"] = struser + " - Survey User";
}
}
Cmb_UserName.TextField = "USER_NAME";
Cmb_UserName.ValueField = "USER_ID";
Cmb_UserName.DataSource = dtMainBranchUsers;
Cmb_UserName.DataBind();
Now, I need to differentiate based on USER_LEVEL
and show colors.
Is this possible?
From DevExpress
I'm afraid, the ASPxListBox (which is the part of the ASPxComboBox) doesn't allow to set specific color for each item. I suggest you to use the ASPxDropDownEdit. This control allows to put anything in its DropDownWindowTemplateContainer. For example, you can put the ASPxGridView and set color for each row using the HtmlRowPrepared event handler.
See here.