Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6319191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T15:45:48+00:00 2026-05-24T15:45:48+00:00

<asp:GridView ID=gvStates AutoGenerateColumns=false Width=100% AllowSorting=true runat=server OnRowCreated=gvStates_RowCreated OnRowDataBound=gvStates_RowCreated> <HeaderStyle BackColor=#57768f ForeColor=White /> <RowStyle BackColor=#dae2e8

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

            <asp:BoundField HeaderText="MN Phone" DataField="MN Phone" />
            <asp:BoundField HeaderText="Cell Phone" DataField="Cell Phone" />
        </Columns>
    </asp:GridView>

[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]

I’m trying to bind the ‘ddRec’ dropdown to the Recruiter field in the dataset. I tried
DataTextField='<%#Bind(“Recruiter”)%>’

Edit:

Error: {“Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.”}

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

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

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

    for (int i = 1; i <= _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();
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T15:45:49+00:00Added an answer on May 24, 2026 at 3:45 pm

    You can’t programmatically bind to the DataTextField field; the DataTextField identifies the field to display in the drop down, hence it has to be static and is not evaluated per row. Though, you can tap into the Grid’s RowDataBound event, and programmably set the DataTextField property and bind data at that point.

    HTH.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<asp:GridView ID=GridView3 runat=server Width=100% DataSourceID=SDSAllowPaging=True AutoGenerateColumns=False > <Columns> <asp:BoundField DataField=Hint HeaderText=textSortExpression=Hint /> <asp:BoundField DataField=Visi
I have an asp:GridView declared as follows: <asp:GridView runat=server id=dg_myprojects AllowSorting=true AutoGenerateColumns=false Width=900px CssClass=Grid
Below is my gridview <asp:GridView ID=GridView1 runat=server AutoGenerateColumns=False EnableModelValidation=True onrowdatabound=GridView1_RowDataBound onrowcommand=GridView1_RowCommand onrowdeleting=GridView1_RowDeleting> <asp:TemplateField HeaderText=Amount
I have a gridview like below: <asp:GridView DataKeyNames=TransactionID AllowSorting=True AllowPaging=TrueID=grvBrokerage runat=server AutoGenerateColumns=False CssClass=datatable Width=100%
I have a Gridview <asp:GridView ID=GridView1 runat=server Width=400px AutoGenerateColumns=false OnSelectedIndexChanged=GridView1_SelectedIndexChanged1> <Columns> <asp:TemplateField> <ItemTemplate> <asp:CheckBox
I have a simple gridview <asp:GridView ID=GridView1 runat=server DataKeyNames=OriginatorID AutoGenerateColumns=False AllowPaging=True OnPageIndexChanging=GridView1_PageIndexChanging PageSize=5 OnPreRender=GridView1_PreRender>
I have an ASP.Net GridView with properties like so: <asp:GridView ID=grdOrderEntry runat=server AutoGenerateColumns=false ShowFooter=True
I'm defining a GridView as follows: <asp:GridView ID=MediaViewsGrid DataSourceID=MediaViewsDataSource runat=server AutoGenerateColumns=False> <Columns> <asp:CommandField ShowEditButton=True
Given a GridView control defined like this: <asp:GridView ID=AttachedFilesGridView runat=server AllowSorting=true AllowPaging=false CellPadding=5 AutoGenerateColumns=false
<asp:GridView ID=GridView2 runat=server AllowPaging=True AutoGenerateColumns=False DataSourceID=opendiarysource Font-Size=Small style=font-size: 8pt; border-top-style: solid; border-right-style: solid; border-left-style:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.