Füllen Sie die Dropdown-Liste in einer Rasteransicht aus

Ich habe eine Dropdown-Liste in einer Rasteransicht und muss die mit jeder ID verknüpften Datensätze anzeigen. Und die ID enthält mehr als 10 Datensätze. Wie kann ich sie anzeigen?

 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                con.Open();
                var ddl = (DropDownList)e.Row.FindControl("DropDownList1");
                //int CountryId = Convert.ToInt32(e.Row.Cells[0].Text);
                SqlCommand cmd = new SqlCommand("select LastName from Profile_Master",        con);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataSet ds = new DataSet();
                da.Fill(ds);
                con.Close();
                ddl.DataSource = ds;
                ddl.DataTextField = "LastName";
                ddl.DataBind();

            }
        }

Antworten auf die Frage(2)

Ihre Antwort auf die Frage