<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]
'ddRec'드롭 다운을 데이터 집합의 Recruiter 필드에 바인딩하려고합니다. 나는 시도 DataTextField = '<퍼센트 번호 바인드 ("모집") %>'바인딩 프로그래밍 방식으로 격자보기에서 드롭 다운
편집 :
오류 : 그런 평가(), XPath는()와 바인딩 (같은 { "데이터 바인딩 방법) 할 수 있습니다 만 데이터 바인딩 된 컨트롤의 컨텍스트에서 사용할 수 있습니다. "}
더 잘 설명해 드리겠습니다. 내가 생각하는 OnRowCreated 이벤트에 대한 쿼리에서 채워되고있는 PROC하지만 드롭 다운 목록 자체에서 값을 설정하기 위해 노력하고있어이 내 문제를 프로그래밍 방식으로 DataTextField 필드에 바인딩 할 수 없습니다
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();
}
}
"좋지 않다"어떻게? –