我们正在使用Repeater控件动态添加控件部分。
每个部分包含多个列。
用户输入一个部分的信息,如果需要,可点击添加其他部分以获取更多信息。
我们正在使用多视图控件。
View1用于用户数据输入。 View2用于预览数据,如果一切正常,则提交记录。
这很有效。
我遇到的问题是为用户提供预览页面以查看他们输入的信息。
最初,我们能够预览输入的任何记录。
从昨天起,当我们添加更多表单字段时,突然,当您单击预览页面时,它会显示为空白。
知道可能出现什么问题吗?
抱歉,长代码。我发布了我认为相关的代码。
private void SetRowData2()
{
int rowIndex = 0;
if (ViewState["CurrentTable"] != null)
{
DataTable dt = (DataTable)ViewState["CurrentTable"];
DataRow drCurrentRow = null;
if (dt.Rows.Count > 0)
{
for (int i = 1; i <= dt.Rows.Count; i++)
{
TextBox tbaircity = (TextBox)Repeater2.Items[rowIndex].FindControl("aircraftCity");
TextBox tbaircnty = (TextBox)Repeater2.Items[rowIndex].FindControl("aircraftcnty");
DropDownList tbairstate = (DropDownList)Repeater2.Items[rowIndex].FindControl("aircraftstate");
TextBox tbTextBox2 = (TextBox)Repeater2.Items[rowIndex].FindControl("aRegNo");
TextBox tbTextBox3 = (TextBox)Repeater2.Items[rowIndex].FindControl("aMake");
TextBox tbTextBox4 = (TextBox)Repeater2.Items[rowIndex].FindControl("aModelNo");
TextBox tbTextBox5 = (TextBox)Repeater2.Items[rowIndex].FindControl("aYRBuilt");
TextBox tbTextBox6 = (TextBox)Repeater2.Items[rowIndex].FindControl("aSN");
TextBox tbdatePurchased = (TextBox)Repeater2.Items[rowIndex].FindControl("txtdatePurchased");
RadioButtonList tbPurchaseType = (RadioButtonList)Repeater2.Items[rowIndex].FindControl("rblPurchaseType");
TextBox tbPrevOnwerName = (TextBox)Repeater2.Items[rowIndex].FindControl("txtPrevOnwerName");
TextBox tbprevAddr = (TextBox)Repeater2.Items[rowIndex].FindControl("txtprevAddr");
TextBox tbprevCity = (TextBox)Repeater2.Items[rowIndex].FindControl("txtprevCity");
DropDownList tbPrevState = (DropDownList)Repeater2.Items[rowIndex].FindControl("ddlPrevState");
TextBox tbprevzip = (TextBox)Repeater2.Items[rowIndex].FindControl("txtprevzip");
TextBox tbbuyername = (TextBox)Repeater2.Items[rowIndex].FindControl("txtbuyername");
TextBox tbbuyeraddress = (TextBox)Repeater2.Items[rowIndex].FindControl("txtbuyeraddress");
TextBox tbbuyercity = (TextBox)Repeater2.Items[rowIndex].FindControl("txtbuyercity");
DropDownList tbbuyerstate = (DropDownList)Repeater2.Items[rowIndex].FindControl("lblbuyerstate");
TextBox tbbuyerzip = (TextBox)Repeater2.Items[rowIndex].FindControl("txtbuyerzip");
TextBox tbdatesold = (TextBox)Repeater2.Items[rowIndex].FindControl("txtdatesold");
TextBox tbsalePrice = (TextBox)Repeater2.Items[rowIndex].FindControl("txtsalePrice");
TextBox tbdescription = (TextBox)Repeater2.Items[rowIndex].FindControl("txtDescription");
TextBox tbTextBox9 = (TextBox)Repeater2.Items[rowIndex].FindControl("aircraftCost");
TextBox tbBtwnTBO = (TextBox)Repeater2.Items[rowIndex].FindControl("hrsBtwnTBO");
TextBox tbOverhaul = (TextBox)Repeater2.Items[rowIndex].FindControl("hrsOverhaul");
RadioButtonList tbrbllastOverHaul = (RadioButtonList)Repeater2.Items[rowIndex].FindControl("rbllastOverHaul");
TextBox tbTotalOnAirFrm = (TextBox)Repeater2.Items[rowIndex].FindControl("TotOnAirFrm");
TextBox tbAvionics = (TextBox)Repeater2.Items[rowIndex].FindControl("txtavionics");
RadioButtonList tbissues = (RadioButtonList)Repeater2.Items[rowIndex].FindControl("rblIssues");
TextBox tbissuedetails = (TextBox)Repeater2.Items[rowIndex].FindControl("functionalIsses");
drCurrentRow = dt.NewRow();
drCurrentRow["RowNumber"] = i + 1;
dt.Rows[i - 1]["aircity"] = tbaircity.Text;
dt.Rows[i - 1]["aircnty"] = tbaircnty.Text;
dt.Rows[i - 1]["airstate"] = tbairstate.Text;
dt.Rows[i - 1]["aRegNo"] = tbTextBox2.Text;
dt.Rows[i - 1]["Make"] = tbTextBox3.Text;
dt.Rows[i - 1]["ModelNo"] = tbTextBox4.Text;
dt.Rows[i - 1]["YRBuilt"] = tbTextBox5.Text;
dt.Rows[i - 1]["SN"] = tbTextBox6.Text;
dt.Rows[i - 1]["txtdatePurchased"] = tbdatePurchased.Text;
dt.Rows[i - 1]["rblPurchaseType"] = tbPurchaseType.Text;
dt.Rows[i - 1]["rblPurchaseType"] = tbPurchaseType.Text;
dt.Rows[i - 1]["PrevOnwerName"] = tbPrevOnwerName.Text;
dt.Rows[i - 1]["prevAddr"] = tbprevAddr.Text;
dt.Rows[i - 1]["prevCity"] = tbprevCity.Text;
dt.Rows[i - 1]["PrevState"] = tbPrevState.Text;
dt.Rows[i - 1]["prevzip"] = tbprevzip.Text;
dt.Rows[i - 1]["buyername"] = tbprevzip.Text;
dt.Rows[i - 1]["buyeraddress"] = tbprevzip.Text;
dt.Rows[i - 1]["buyercity"] = tbprevzip.Text;
dt.Rows[i - 1]["buyerstate"] = tbprevzip.Text;
dt.Rows[i - 1]["buyerzip"] = tbprevzip.Text;
dt.Rows[i - 1]["datesold"] = tbprevzip.Text;
dt.Rows[i - 1]["salePrice"] = tbprevzip.Text;
dt.Rows[i - 1]["description"] = tbprevzip.Text;
dt.Rows[i - 1]["aCost"] = tbTextBox9.Text;
dt.Rows[i - 1]["BtwnTBO"] = tbBtwnTBO.Text;
dt.Rows[i - 1]["Overhaul"] = tbOverhaul.Text;
dt.Rows[i - 1]["rbllastOverHaul"] = tbrbllastOverHaul.Text;
dt.Rows[i - 1]["TotalOnAirFrm"] = tbBtwnTBO.Text;
dt.Rows[i - 1]["Avionics"] = tbAvionics.Text;
dt.Rows[i - 1]["rissues"] = tbAvionics.Text;
dt.Rows[i - 1]["issuedetails"] = tbAvionics.Text;
rowIndex += 1;
}
ViewState["CurrentTable"] = dt;
}
}
else
{
Response.Write("ViewState is null");
}
}
//preview of data
private void FillSummary()
{
SetRowData2();
int rowIndex = 0;
if (ViewState["CurrentTable"] != null)
{
////Initialize datatable.
DataTable ctable = ViewState["CurrentTable"] as DataTable;
////Lets start looping through the second datatable for aircraft schedule info. .
if (ctable.Rows.Count > 0)
{
foreach (DataRow row in ctable.Rows)
{
//Aircraft schedule
string acity = row.ItemArray[1] as string;
string acnty = row.ItemArray[2] as string;
string arstate = row.ItemArray[3] as string;
string Regno = row.ItemArray[4] as string;
string mfgmake = row.ItemArray[5] as string;
string mfgmodel = row.ItemArray[6] as string;
string yrbuilt = row.ItemArray[7] as string;
string sn = row.ItemArray[8] as string;
string dtepurchased = row.ItemArray[9] as string;
string rbPurchaseType = row.ItemArray[10] as string;
//Previous Onwer info
string PrevOnwerName = row.ItemArray[11] as string;
string prevAddr = row.ItemArray[12] as string;
string prevCity = row.ItemArray[13] as string;
string PrevState = row.ItemArray[14] as string;
string prevzip = row.ItemArray[15] as string;
//New buyer info
string buyername = row.ItemArray[16] as string;
string buyeraddress = row.ItemArray[17] as string;
string buyercity = row.ItemArray[18] as string;
string buyerstate = row.ItemArray[19] as string;
string buyerzip = row.ItemArray[20] as string;
string datesold = row.ItemArray[21] as string;
string salePrice = row.ItemArray[22] as string;
string decription = row.ItemArray[23] as string;
string cost = row.ItemArray[24] as string;
string hrsbtwn = row.ItemArray[25] as string;
string hrsSince = row.ItemArray[26] as string;
string LOverhaul = row.ItemArray[27] as string;
string totHrs = row.ItemArray[28] as string;
string avionics = row.ItemArray[29] as string;
string rissues = row.ItemArray[30] as string;
string issuedetails = row.ItemArray[31] as string;
//Preparing to preview user entries
lblAircraftCity.Text += acity + "<br />";
lblAircraftcnty.Text += acnty + "<br />";
lAblircraftstate.Text += arstate + "<br />";
lblARegNo.Text += Regno + "<br />";
lblAMake.Text += mfgmake + "<br />";
lblAModelNo.Text += mfgmodel + "<br />";
lblAYRBuilt.Text += yrbuilt + "<br />";
lblASN.Text += sn + "<br />";
lblDatePurchased.Text += dtepurchased + "<br />";
if (rbPurchaseType != null)
{
lblPurchType.Text += rbPurchaseType + "<br />";
}
lblFNamePrev.Text += PrevOnwerName + "<br />";
lblAddrPrev.Text += prevAddr + "<br />";
lblCityPrev.Text += prevCity + "<br />";
lblZipPrev.Text += prevzip + "<br />";
lblPurchOnwer.Text += buyername + "<br />";
lblPurchOnwer.Text += buyername + "<br />";
lblPurcAddr.Text += buyeraddress + "<br />";
lblPurcCity.Text += buyercity + "<br />";
Label1.Text += buyerstate + "<br />";
lblPurcZip.Text += buyerzip + "<br />";
lblDdatesold.Text += datesold + "<br />";
lblSalePrice.Text += salePrice + "<br />";
lblDescription.Text += decription + "<br />";
Label3.Text += rissues + "<br />";
lblfunctionalIsses.Text += issuedetails + "<br />";
lblAircraftCost.Text += cost + "<br />";
lblHrsBtwnTBO.Text += hrsbtwn + "<br />";
lblHrsOverhaul.Text += hrsSince + "<br />";
if (LOverhaul != null)
{
lblOverhaul.Text += LOverhaul + "<br />";
}
lblTotOnAirFrm.Text += totHrs + "<br />";
lblavionics.Text += avionics + "<br />";
if (rissues != null)
{
lblsitus.Text += rissues + "<br />";
}
lblfunctionalIsses.Text += issuedetails + "<br />";
rowIndex += 1;
}
}
}