Assuming that gameData
is the db item you want to select if it does exist, you can use ListItemCollection.FindByValue
to get the item or null
if it does not exist. Then you can set DropDownList.SelectedValue
to select it:
string selectedValue = "Others";
if(ddlgameTile.Items.FindByValue(gameData) != null)
selectedValue = gameData;
ddlgameTile.SelectedValue = selectedValue;
However, if you have set the DataValueField
and DataTextField
you have to use FindByText
.