How can I solve a NullReferenceException?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-in-net">What is a NullReferenceException in .NET?</a>  </p>
</blockquote>



<p>I am a beginner in MVC and I have tried to add a dropdown list to save its selected value in database using sql queries but my code throws a <code>NullReferenceException</code>.</p>

<p>Can anyone help me please?</p>

<p>This is the model</p>

<pre><code>public class caradvert
{
    [Required]
    public SelectList GearType { get; set; }

    public int Selected { get; set; }

public caradvert()
{
    List&lt;SelectListItem&gt; listItems = new List&lt;SelectListItem&gt;();
    listItems.Add(new SelectListItem()
    {
        Value = "0",
        Text = "اتوماتيك "
    });


    listItems.Add(new SelectListItem()
    {
        Value = "1",
        Text = "عادي"
    });

        GearType = new SelectList(listItems, "Value", "Text");
}

public int CreatAdvert(int userid)
    {

        SqlConnection objConn = new SqlConnection("Data Source=ADMIN-PC;Initial Catalog=mvc4advertisment;Integrated Security=True");
        SqlCommand objCmd = new SqlCommand();
        objCmd.CommandType = CommandType.Text;
        objCmd.CommandText = "insert into Mercedes(Model,GearType,color,EngineCapacity,CarDescription,Price,Image1Url,Image2Url,Image3Url,Userid,State) values('1','" + GearType.SelectedValue.ToString() + "','r','221','ddd','2','ss','ss','ss','1','False')";
        objCmd.Connection = objConn;
        objConn.Open();
        int count = (int)objCmd.ExecuteNonQuery();
        objConn.Close();
        return count;
    }
}
</code></pre>

<p>This is controller</p>

<pre><code>   [HttpGet]
    public ActionResult CreateAdvert()
    {

        caradvert model = new caradvert();
        List&lt;SelectListItem&gt; listItems = new List&lt;SelectListItem&gt;();
        listItems.Add(new SelectListItem()
        {
            Value = "1",
            Text = "اتوماتيك "
        });


        listItems.Add(new SelectListItem()
        {
            Value = "1",
            Text = "عادي"
        });
        model.GearType = new SelectList(listItems, "Value", "Text");



        return View(model);


    }

    [HttpPost]
    public ActionResult CreateAdvert(caradvert model )
    {
                int _records = model.CreatAdvert(1);
                if (_records &gt; 0)
                {
                    return RedirectToAction("Index", "Account");
                }
                else
                {
                    ModelState.AddModelError("", "لا يمكنك اضافة اعلان");
                }

        return View(model);

    }
</code></pre>

<p>This is the view</p>

<pre><code>&lt;%:Html.DropDownListFor(m=&gt;m.Selected,Model.GearType,") %&gt;
</code></pre>
