Q:

how to select value by default in dropdown list when use viewdata["Country"] and get get list from database

i have country list stored in database and using viewdata to store all list now when i edit my task then i want to set my value in dropdown list. my code is
 public ActionResult Edit(long EventId)
        {
            using (Event objEvent = new Event())
            {
                List<EventObject> lst = new List<EventObject>();
                lst = objEvent.GetEventByEventId(EventId);

                using (Country objContry = new Country())
                {
                    ViewData["Country"] = new SelectList(objContry.GetAllCountry(), "Country", "Country");
                }

                return View(lst[0]);
            }
        }

at lst[0].Country is my a value which i want to selected by default in dropdownlist.
my view is
    <h5>Country</h5>
 @Html.DropDownListFor(model => model.Country, (SelectList)ViewData["Country"], new { id = "ddlCountry" })

A:

You seem to be binding the dropdown to a complex property on your model (Country) which obviously is not supported. Dropdowns should be bound only to simple scalar type properties. So you should define a property that will hold the selected value on your EventObject view model:
public string SelectedCountry { get; set; }

Then in your controller action you should set this property to the value of the country you want to be preselected:
using (Country objContry = new Country())
{
    ViewData["Countries"] = new SelectList(objContry.GetAllCountry(), "Country", "Country");
}

lst[0].SelectedCountry = "Argentina";

return View(lst[0]);

and in your view:
@Html.DropDownListFor(
    model => model.SelectedCountry, 
    (SelectList)ViewData["Country"], 
    new { id = "ddlCountry" }
)

In case your Country property is a scalar type you could directly assign a value to it:
lst[0].Country = "Argentina";

