المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Select a perticular value in combo box



C# Programming
12-22-2009, 02:10 PM
Hi,
I've a combo box, which contains Sites' names(data comes from database). One of the item is "Create new site". I would like to keep the "Create new site" item at the top of all items. I tried to accomplish this by setting SelectedValue to 0, But it didn't work. Below is my code. Please guide to solve this issue. Thanks in advance.


DataTable dtSite = new DataTable();
DataRow drNewAction;

dtSite = objSites.SelectSites();
drNewAction = dtSite.NewRow();
drNewAction["SiteKey"] = 0;
drNewAction["SiteName"] = "Create new site";
dtSite.Rows.Add(drNewAction);

comSiteList.DataSource = dtSite;
comSiteList.DisplayMember = "SiteName";
comSiteList.ValueMember = "SiteKey";
comSiteList.Tag = "Loaded";
comSiteList.SelectedValue = 0;