내 질문에 자체적으로 설명하기를 바랍니다. =) 모든 것을 시도했지만 작동하지 않는 이유가없는 것 같습니다!CheckBoxList 바인딩 오류 (System.Data.Common.DataRecordInternal)
내 CheckBoxList :
<asp:CheckBoxList ID="chkbxlstCuisines" runat="server">
</asp:CheckBoxList>
내 코드 숨김 :
protected void Page_Load(object sender, EventArgs e)
{
string cuisinesSelectStatement = "SELECT Cuisines.CuisineId, Cuisines.CuisineType FROM Cuisines";
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["MyDbConnection"].ConnectionString);
SqlCommand comm = new SqlCommand(cuisinesSelectStatement , conn);
SqlDataReader reader1;
conn.Open();
reader1 = comm.ExecuteReader();
chkbxlstCuisines.DataSource = reader1;
chkbxlstCuisines.DataBind();
while (reader1.Read())
{
chkbxlstCuisines.DataValueField = reader1["CuisineId"].ToString();
chkbxlstCuisines.DataTextField = reader1["CuisineType"].ToString();
}
//conn.Close();
}
나는 사람이, 내가 전에이 오류를 수정하기 때문에거야 약간의 실수가 될 것을 알고 그것을 알아낼 희망하지만 지금 정말로 무엇이 잘못되었는지 모릅니다! 미리 감사드립니다. =)
편집 :
I 출력이 다섯 확인란을하고 내 데이터베이스 정확히 5 개 항목이 포함되어 있기 때문에 문제가, 주조와 생각!
출력 :
이System.Data.Common.DataRecordInternal
System.Data.Common.DataRecordInternal
System.Data.Common.DataRecordInternal
System.Data.Common.DataRecordInternal
감사합니다. Andrey, 게시물 1 분 전에 알아 냈지만 바인딩 후 DataValueField 및 DataTextField 속성을 할당했습니다. 귀하와 마찬가지로 연결하기 전에 그들을 배치했습니다 지금 완벽하게 작동합니다 (Y) – lKashef