Linq C# pulling from table row into input fields Today is the first time I've used Linq, so I wanted to get a code review on this and make sure I'm going about it correctly.

I'm filling text boxes and dropdown lists from a table row.

protected void Page_Load(object sender, EventArgs e)
        {

            using (DBContext da = new DBContext())
            {
                string dob;
                var detail = from a in da.tblPatients
                             where a.ID == 1198
                             select a;
                foreach (var d in detail)
                {

                    txtFirstName.Text = d.FirstName;
                    txtLastName.Text = d.LastName;
                    txtPreferredName.Text = d.PreferredName;
                    dob = d.DOB;
                    if(!String.IsNullOrEmpty(dob))
                    {
                        try
                        {
                            int lastindexofdob = 0;
                            string month = "";
                            string day = "";
                            string year = "";
                            lastindexofdob = dob.LastIndexOf("/");
                            month = dob.Substring(0, dob.IndexOf("/"));
                            day = dob.Substring(month.Length + 1, (dob.LastIndexOf("/") - month.Length) - 1);
                            year = dob.Substring(dob.Length - 4);

                            ddlDOBMonth.SelectedIndex = ddlDOBMonth.Items.IndexOf(ddlDOBMonth.Items.FindByValue(month));
                            ddlDOBDay.SelectedIndex = ddlDOBDay.Items.IndexOf(ddlDOBDay.Items.FindByText(day));
                            ddlDOBYear.SelectedIndex = ddlDOBYear.Items.IndexOf(ddlDOBYear.Items.FindByText(year));
                        }
                        catch { //error catching will go here}

                    }
                    txtAddress.Text = d.Address;
                }
            }  

        }


There are actually about 20 more input fields to do, but I wanted a code review at this point.
Your use of linq is fine.

You may consider using a more descriptive variable than a, such as patient

You should pass any query parameters likely to change as variables. Consider:

var patientID = 1198;
var detail = from patient in da.tblPatients
             where patient.ID == patientID
             select patient;


I find the form population logic and database design to be a touch more troubling. txtFirstName.Text = d.FirstName is perfectly fine. DOB, which I assume to be date of birth should be stored and used as a Date rather than a String.

If you are unable to change the data-layer, at least convert it to a Date for use using Date.Parse or similar.

Your try block is lazy coding. Check the results from your dob.IndexOf and 'dob.Substring' calls rather than relying on catching an error -- be defensive in your code. Consider the following:

DateTime dob = DateTime.MinValue;
if (DateTime.TryParse(d.DOB, dob))
{
    ddlDOBMonth.SelectedValue = dob.Month.ToString();
    ddlDOBDay.SelectedValue = dob.Day.ToString();
    ddlDOBYear.SelectedValue = dob.Year.ToString();
}