0
다음은 하나의 제목 뒤에 하나의 을 표시하는 코드입니다.중계기를 사용하는 다중 체크 박스 목록
마크 업 : 뒤에
<asp:Repeater id="repRoles" runat="server">
<ItemTemplate>
<asp:literal runat="server" text=<%# DataBinder.Eval(Container.DataItem, "ItemTitle") %>></asp:literal>
<br />
<asp:CheckBoxList runat="server" DataSourceID=<%# FillinCbl(DataBinder.Eval(Container.DataItem,"ItemID").ToString()) %>
DataTextField="ItemName" DataValueField="ItemValue">
</asp:CheckBoxList>
</ItemTemplate>
</asp:Repeater>
코드 :에만 문자가 표시되고
private void FillinRepeater()
{
try
{
List<Item> targetAudienceParent = new List<Item>();
DataTable tempTbl = new DataTable();
tempTbl.Columns.Add("ItemTitle", typeof(String));
tempTbl.Columns.Add("ItemID", typeof(String));
DataRow tempRow;
int tempCount = 0;
foreach (Item a in itmECM.Children)
{
try
{
tempRow = tempTbl.NewRow();
tempRow["ItemTitle"] = a.Name.ToString();
tempRow["ItemID"] = a.ID.ToString();
tempTbl.Rows.Add(tempRow);
tempCount++;
}
catch
{
}
}
repRoles.DataSource = tempTbl;
repRoles.DataBind();
}
catch
{
}
}
public DataTable FillinCbl(String passedString)
{
dtlRoles = new DataTable();
dtlRoles.Columns.Add("Name", typeof(String));
dtlRoles.Columns.Add("OptInID", typeof(String));
dtlRoles.Columns.Add("OptOutID", typeof(String));
Item tempItm = master.GetItem(passedString);
DataTable tempTbl = new DataTable();
tempTbl.Columns.Add("ItemName", typeof(String));
tempTbl.Columns.Add("ItemValue", typeof(String));
DataRow tempRow;
try
{
populateUsersList(tempItm);
Session["dtlRoles"] = dtlRoles;
for (int a = 0; a < dtlRoles.Rows.Count; a++)
{
try
{
Response.Write(dtlRoles.Rows[a][0].ToString().Trim() + "<br/>");
tempRow = tempTbl.NewRow();
tempRow["ItemName"] = dtlRoles.Rows[a][0].ToString().Trim();
tempRow["ItemValue"] = dtlRoles.Rows[a][1].ToString().Trim();
tempTbl.Rows.Add(tempRow);
}
catch(Exception ex1)
{
Response.Write(ex1.ToString() + "<br/>");
}
}
}
catch (Exception ex2)
{
Response.Write(ex2.ToString() + "<br/>");
}
return tempTbl;
}
문제가된다. checkboxlist
이 (가) 입력되지 않았습니다.
response.write()
의 경우 의 경우 checobxlist
인 경우 해당 값이 출력되지 않습니다.
내 코드가 작동하고 있습니다. 뭔가 빠져 있습니다. 그러나 나는 무엇을 발견 할 수 없다.
종류를 데이터 소스입니다. 나는'DataSource' 메쏘드가'FillInCbl'을 호출하고'DataTable'가 값으로 채워지는지 테스트했습니다. 그것은 단지'checkboxlist'에 바인딩되지 않습니다. – william