안녕하세요, 저는 프로그래밍을 시작한 후 문제가 있습니다. 새로운 Datatable 나는 button1 클릭하면 GridView2에서 나던 보여줬습니다. "계획"테이블의 데이터로 채워져 있지만 (dtPlanning이 주석의 TextBoxes로 채워지는지 확인).DataTable을 GridView에 바인딩 할 수 없습니다.
요약하면 DataTable 계획을 새 DataTable dtPlanning에 가져 와서 gridview에 표시하려고합니다. 뒤에
코드 :
protected void Button1_Click(object sender, EventArgs e)
{
DataTable dtPlanning = new DataTable();
dtPlanning.Columns.Add("Courseday", typeof(int));
dtPlanning.Columns.Add("Part", typeof(string));
dtPlanning.Columns.Add("Design", typeof(string));
dtPlanning.Columns.Add("Lesson", typeof(string));
//DataRow dr = planning.Rows[1];
//TextBox2.Text = (dr["Daynumber"]).ToString();
//TextBox3.Text = (dr["Part"]).ToString();
//TextBox4.Text = (dr["Design"]).ToString();
//TextBox5.Text = (dr["Lesson"]).ToString();
for (int i = 0; i < dtPlanning.Rows.Count; i++)
{
DataRow dr = dtPlanning.NewRow();
foreach (DataRow datarow in planning.Rows)
{
dtPlanning.Rows.Add(datarow);
}
}
GridView2.DataSource = dtPlanning;
GridView2.DataBind();
}
소스 코드 :
<asp:GridView ID="GridView2" runat="server">
는 당신의 도움을 주셔서 감사합니다.
dtPlanning은 비어 있습니다. 모든 코드가 아닙니다. – codingbiz
계획 수표를 확인하십시오. 행 개수 및 데이터 – andy
이걸로 무엇을하고 싶니? – codingbiz