Binding Drop down in grid view programatically
<pre><code>&lt;asp:GridView ID="gvStates" AutoGenerateColumns="false" Width="100%" AllowSorting="true" 
                  runat="server" OnRowCreated="gvStates_RowCreated" 
                  OnRowDataBound="gvStates_RowCreated"&gt;
        &lt;HeaderStyle BackColor="#57768f" ForeColor="White" /&gt;
        &lt;RowStyle BackColor="#dae2e8" ForeColor="Black" HorizontalAlign="Center" /&gt;
        &lt;AlternatingRowStyle BackColor="#ffffff" ForeColor="Black" /&gt;
        &lt;Columns&gt;
            &lt;asp:BoundField HeaderText="key" DataField="key" /&gt;
            &lt;asp:BoundField HeaderText="Name" DataField="Name" /&gt;
            &lt;asp:BoundField HeaderText="Quota" DataField="Quota" /&gt;
            &lt;asp:BoundField HeaderText="Session" DataField="Sess" &gt;
                &lt;ItemStyle HorizontalAlign="Center" /&gt;
            &lt;/asp:BoundField&gt;
            &lt;asp:TemplateField HeaderText=""&gt;
                &lt;ItemTemplate&gt;
                    &lt;asp:DropDownList ID="ddlSess" Width="100%" AutoPostBack="true" runat="server" OnSelectedIndexChanged="ddl"&gt;
                    &lt;/asp:DropDownList&gt;
                &lt;/ItemTemplate&gt;
            &lt;/asp:TemplateField&gt;
            &lt;asp:TemplateField HeaderText="Scheduled"&gt;
                &lt;ItemTemplate&gt;
                    &lt;asp:CheckBox ID="CheckBox1" runat="server" Checked='&lt;%#Bind("Sched")%&gt;' Enabled="false" /&gt;
                &lt;/ItemTemplate&gt;
                &lt;EditItemTemplate&gt;
                    &lt;asp:CheckBox ID="CheckBox1" runat="server" Checked='&lt;%#Bind("Sched")%&gt;' /&gt;
                &lt;/EditItemTemplate&gt;
                &lt;ItemStyle HorizontalAlign="Center" /&gt;
            &lt;/asp:TemplateField&gt;
            &lt;asp:TemplateField HeaderText=""&gt;
                &lt;ItemTemplate&gt;
                    &lt;asp:Button ID="_b_SchStat" runat="server" AutoPostBack="true" Text="UnSchedule" OnClick="_b_ToggleSched" /&gt;
                &lt;/ItemTemplate&gt;
                &lt;ItemStyle HorizontalAlign="Center" /&gt;
            &lt;/asp:TemplateField&gt;
            &lt;asp:TemplateField HeaderText="Recruiter"&gt;
                &lt;ItemTemplate&gt;
                    &lt;asp:DropDownList ID="ddRec" Width="100%" AutoPostBack="true" runat="server" OnSelectedIndexChanged="ddR"&gt;
                    &lt;/asp:DropDownList&gt;
                &lt;/ItemTemplate&gt;
            &lt;/asp:TemplateField&gt;

            &lt;asp:BoundField HeaderText="MN Phone" DataField="MN Phone" /&gt;
            &lt;asp:BoundField HeaderText="Cell Phone" DataField="Cell Phone" /&gt;
        &lt;/Columns&gt;
    &lt;/asp:GridView&gt;

[dbo].[QRY_RecruitGrid]
@jobnum     varchar(20),
@quota          varchar(10),
@sess           VARCHAR(10)
AS
SELECT 
[job_resp_recordid] as 'key'
,[job_resp_name] as 'Name'
,[job_resp_quota] as 'Quota' 
,[job_resp_session] as 'Sess'
,[job_resp_scheduled] as 'Sched' 
,COALESCE([job_resp_recruited_by], '') as 'Recruiter'
,case when len(ltrim(rtrim([job_resp_phone])))='10' then '('+SUBSTRING([job_resp_phone],1,3)+')'+'      '+SUBSTRING([job_resp_phone],4,3)+'-'+SUBSTRING([job_resp_phone],7,4) when len(ltrim(rtrim([job_resp_phone])))='' then ' ' end AS [MN   Phone]
,case when len(ltrim(rtrim([job_resp_cellphone])))='10' then '('+SUBSTRING([job_resp_cellphone],1,3)+')'+'   '+SUBSTRING([job_resp_cellphone],4,3)+'-'+SUBSTRING([job_resp_cellphone],7,4) when len(ltrim(rtrim([job_resp_cellphone])))='' then ' '  end AS [Cell Phone] 
FROM [dbo].[tbl_job_respondents] 
WHERE job_resp_job_number like @jobnum 
and job_resp_quota like @quota 
AND job_resp_session LIKE @sess
order by job_resp_quota, [job_resp_name]
</code></pre>

<p>I'm trying to bind the 'ddRec' dropdown to the Recruiter field in the dataset.  I tried
    DataTextField='&lt;%#Bind("Recruiter")%>'</p>

<p>Edit:</p>

<p>Error: {"Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control."}</p>

<p>Let me explain better sorry.  I'm trying to set the value from the proc but the dropdown list itself is being populated from a query on the OnRowCreated Event I think this is my problem</p>

<pre><code>protected void gvStates_RowCreated(object sender, GridViewRowEventArgs e)
{
var drop = new List&lt;string&gt; { "" };

    var LNQ = new LNQDataContext();
    var Rec = LNQ.Recruits.Where(c =&gt; c.Active == "Y").Select(c =&gt; new { c.Name });
    var Rdp = new List&lt;string&gt; { "" };
    foreach (var a in Rec) { Rdp.Add(a.Name); }

    for (int i = 1; i &lt;= _cnt; i++) { drop.Add("S" + i); }
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        var ddl = (DropDownList)e.Row.FindControl("ddlSess");
        ddl.DataSource = drop;
        ddl.DataBind();

        var ddR = (DropDownList)e.Row.FindControl("ddRec");
        ddR.DataSource = Rdp;
        ddR.DataBind();
    }
}
</code></pre>
