我希望将Gridview1中的DataTable1中的学生注册号绑定到DataTable2中的位置。 但是,Gridview1第一页只绑定,第二页以后没有绑定。我给出了我的.net代码,DB表结构和Gridview1显示。如果有人给我解决方案,我会感激你的。
private void dgvHallSeating()
{
DataSet ds = new DataSet();
DataTable dt;
DataTable dtSeatPositionsAssign = new DataTable();
DataColumn col1;
DataColumn col2;
DataColumn col3;
DataColumn col4;
DataColumn col5;
dt = new DataTable();
col1 = new DataColumn("col1", Type.GetType("System.String"));
col2 = new DataColumn("col2", Type.GetType("System.String"));
col3 = new DataColumn("col3", Type.GetType("System.String"));
col4 = new DataColumn("col4", Type.GetType("System.String"));
col5 = new DataColumn("col5", Type.GetType("System.String"));
dtSeatPositionsAssign.Columns.Add(col1);
dtSeatPositionsAssign.Columns.Add(col2);
dtSeatPositionsAssign.Columns.Add(col3);
dtSeatPositionsAssign.Columns.Add(col4);
dtSeatPositionsAssign.Columns.Add(col5);
Int32 SeatPositionColIndex = 0;
Int32 SeatPositionRowIndex = 0;
DataTable DataTable2 = new DataTable();
DataTable2 = CMSBL.dtecSeatSlot1Positions();
DataTable DataTable1 = CMSBL.rptecSeatSlot1Reports();
int RegNoRowIndex = 0;
int HallSeatPosition = 0;
for (; RegNoRowIndex < 11; RegNoRowIndex++)
{
for (; HallSeatPosition < DataTable2.Rows.Count; )
{
SeatPositionColIndex = Convert.ToInt32(DataTable2.Rows[HallSeatPosition]["ecGridColumnIndex"]);
SeatPositionColIndex = SeatPositionColIndex - 1;
SeatPositionRowIndex = Convert.ToInt32(DataTable2.Rows[HallSeatPosition]["ecGridRowIndex"]);
SeatPositionRowIndex = SeatPositionRowIndex - 1;
dtSeatPositionsAssign.Rows.Add();
if (SeatPositionRowIndex >= dtSeatPositionsAssign.Rows.Count || GridView1.Rows.Count <= 5)
{
dtSeatPositionsAssign.Rows.Add();
}
dtSeatPositionsAssign.Rows[SeatPositionRowIndex][SeatPositionColIndex] = DataTable1.Rows[RegNoRowIndex][3].ToString();
break;
}
HallSeatPosition++;
}
GridView1.DataSource = dtSeatPositionsAssign;
GridView1.DataBind();
}
**
**